Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
pistache
Commits
c7bbad58
Commit
c7bbad58
authored
Aug 09, 2019
by
Mateusz Szychowski (Muttley)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optional: fix optional being not set
fixes #588
parent
4dc9e3ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
include/pistache/optional.h
include/pistache/optional.h
+10
-5
No files found.
include/pistache/optional.h
View file @
c7bbad58
...
...
@@ -106,6 +106,7 @@ public:
{
if
(
!
other
.
isEmpty
())
{
::
new
(
data
())
T
(
*
other
.
data
());
none_flag
=
ValueMarker
;
}
else
{
none_flag
=
NoneMarker
;
...
...
@@ -153,6 +154,7 @@ public:
data
()
->~
T
();
}
::
new
(
data
())
T
(
*
other
.
data
());
none_flag
=
ValueMarker
;
}
else
{
if
(
none_flag
!=
NoneMarker
)
{
...
...
@@ -237,33 +239,36 @@ private:
void
move_helper
(
Optional
<
T
>
&&
other
,
std
::
true_type
)
{
::
new
(
data
())
T
(
std
::
move
(
*
other
.
data
()));
none_flag
=
ValueMarker
;
}
void
move_helper
(
Optional
<
T
>
&&
other
,
std
::
false_type
)
{
::
new
(
data
())
T
(
*
other
.
data
());
none_flag
=
ValueMarker
;
}
template
<
typename
U
>
void
from_some_helper
(
types
::
Some
<
U
>
some
,
std
::
true_type
)
{
::
new
(
data
())
T
(
std
::
move
(
some
.
val_
));
none_flag
=
ValueMarker
;
}
template
<
typename
U
>
void
from_some_helper
(
types
::
Some
<
U
>
some
,
std
::
false_type
)
{
::
new
(
data
())
T
(
some
.
val_
);
none_flag
=
ValueMarker
;
}
typedef
uint8_t
none_flag_t
;
static
constexpr
none_flag_t
NoneMarker
=
1
;
static
constexpr
none_flag_t
ValueMarker
=
0
;
union
{
uint8_t
bytes
[
sizeof
(
T
)];
none_flag_t
none_flag
;
};
uint8_t
bytes
[
sizeof
(
T
)];
none_flag_t
none_flag
;
};
#define PistacheCheckSize(Type) \
static_assert(sizeof(Optional<Type>) == sizeof(Type), "Size differs")
static_assert(sizeof(Optional<Type>) == sizeof(Type)
+ sizeof(uint8_t)
, "Size differs")
PistacheCheckSize
(
uint8_t
);
PistacheCheckSize
(
uint16_t
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment