Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
1dba5cd5
Commit
1dba5cd5
authored
Apr 13, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add to_string and serialize to optional
parent
290c5214
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
libcaf_core/caf/optional.hpp
libcaf_core/caf/optional.hpp
+31
-0
No files found.
libcaf_core/caf/optional.hpp
View file @
1dba5cd5
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "caf/none.hpp"
#include "caf/none.hpp"
#include "caf/unit.hpp"
#include "caf/unit.hpp"
#include "caf/config.hpp"
#include "caf/config.hpp"
#include "caf/deep_to_string.hpp"
#include "caf/detail/safe_equal.hpp"
#include "caf/detail/safe_equal.hpp"
...
@@ -227,6 +228,36 @@ class optional<T&> {
...
@@ -227,6 +228,36 @@ class optional<T&> {
T
*
m_value
;
T
*
m_value
;
};
};
/// @relates optional
template
<
class
T
>
std
::
string
to_string
(
const
optional
<
T
>&
x
)
{
return
x
?
"!"
+
deep_to_string
(
*
x
)
:
"<none>"
;
}
/// @relates optional
template
<
class
Processor
,
class
T
>
typename
std
::
enable_if
<
Processor
::
is_saving
::
value
>::
type
serialize
(
Processor
&
sink
,
optional
<
T
>&
x
,
const
unsigned
int
)
{
uint8_t
flag
=
x
?
1
:
0
;
sink
&
flag
;
if
(
flag
)
sink
&
*
x
;
}
/// @relates optional
template
<
class
Processor
,
class
T
>
typename
std
::
enable_if
<
Processor
::
is_loading
::
value
>::
type
serialize
(
Processor
&
source
,
optional
<
T
>&
x
,
const
unsigned
int
)
{
uint8_t
flag
;
source
&
flag
;
if
(
flag
)
{
T
value
;
source
&
value
;
x
=
std
::
move
(
value
);
}
x
=
none
;
}
/// @relates optional
/// @relates optional
template
<
class
T
,
class
U
>
template
<
class
T
,
class
U
>
bool
operator
==
(
const
optional
<
T
>&
lhs
,
const
optional
<
U
>&
rhs
)
{
bool
operator
==
(
const
optional
<
T
>&
lhs
,
const
optional
<
U
>&
rhs
)
{
...
...
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