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
2bcb1d2e
Commit
2bcb1d2e
authored
Apr 22, 2016
by
Matthias Vallentin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make has_serialize meta function symmetric
It previously only checked for serialization, not deserialization.
parent
daf900c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
7 deletions
+35
-7
libcaf_core/caf/detail/type_traits.hpp
libcaf_core/caf/detail/type_traits.hpp
+35
-7
No files found.
libcaf_core/caf/detail/type_traits.hpp
View file @
2bcb1d2e
...
@@ -269,7 +269,10 @@ template <class F, class S>
...
@@ -269,7 +269,10 @@ template <class F, class S>
struct
is_tuple
<
std
::
pair
<
F
,
S
>>
:
std
::
true_type
{
};
struct
is_tuple
<
std
::
pair
<
F
,
S
>>
:
std
::
true_type
{
};
/// Checks whether `T` provides either a free function or a member function for
/// Checks whether `T` provides either a free function or a member function for
/// serialization. The following signatures are tested:
/// serialization. The checks test whether both serialization and
/// deserialization can succeed. The meta function tests the following
/// functions with `Processor` being both `serializer` and `deserializer` and
/// returns an integral constant if and only if the test succeeds for both.
///
///
/// - `serialize(Processor&, T&, const unsigned int)`
/// - `serialize(Processor&, T&, const unsigned int)`
/// - `serialize(Processor&, T&)`
/// - `serialize(Processor&, T&)`
...
@@ -280,25 +283,50 @@ template <class T,
...
@@ -280,25 +283,50 @@ template <class T,
||
std
::
is_function
<
T
>::
value
>
||
std
::
is_function
<
T
>::
value
>
struct
has_serialize
{
struct
has_serialize
{
template
<
class
U
>
template
<
class
U
>
static
auto
test
(
caf
::
serializer
*
sink
,
U
*
x
)
static
auto
test
_serialize
(
caf
::
serializer
*
sink
,
U
*
x
)
->
decltype
(
serialize
(
*
sink
,
*
x
,
0u
),
std
::
true_type
());
->
decltype
(
serialize
(
*
sink
,
*
x
,
0u
),
std
::
true_type
());
template
<
class
U
>
template
<
class
U
>
static
auto
test
(
caf
::
serializer
*
sink
,
U
*
x
)
static
auto
test
_serialize
(
caf
::
serializer
*
sink
,
U
*
x
)
->
decltype
(
serialize
(
*
sink
,
*
x
),
std
::
true_type
());
->
decltype
(
serialize
(
*
sink
,
*
x
),
std
::
true_type
());
template
<
class
U
>
template
<
class
U
>
static
auto
test
(
caf
::
serializer
*
sink
,
U
*
x
)
static
auto
test
_serialize
(
caf
::
serializer
*
sink
,
U
*
x
)
->
decltype
(
x
->
serialize
(
*
sink
,
0u
),
std
::
true_type
());
->
decltype
(
x
->
serialize
(
*
sink
,
0u
),
std
::
true_type
());
template
<
class
U
>
template
<
class
U
>
static
auto
test
(
caf
::
serializer
*
sink
,
U
*
x
)
static
auto
test
_serialize
(
caf
::
serializer
*
sink
,
U
*
x
)
->
decltype
(
x
->
serialize
(
*
sink
),
std
::
true_type
());
->
decltype
(
x
->
serialize
(
*
sink
),
std
::
true_type
());
template
<
class
>
template
<
class
>
static
auto
test
(...)
->
std
::
false_type
;
static
auto
test_serialize
(...)
->
std
::
false_type
;
template
<
class
U
>
static
auto
test_deserialize
(
caf
::
deserializer
*
source
,
U
*
x
)
->
decltype
(
serialize
(
*
source
,
*
x
,
0u
),
std
::
true_type
());
template
<
class
U
>
static
auto
test_deserialize
(
caf
::
deserializer
*
source
,
U
*
x
)
->
decltype
(
serialize
(
*
source
,
*
x
),
std
::
true_type
());
template
<
class
U
>
static
auto
test_deserialize
(
caf
::
deserializer
*
source
,
U
*
x
)
->
decltype
(
x
->
serialize
(
*
source
,
0u
),
std
::
true_type
());
template
<
class
U
>
static
auto
test_deserialize
(
caf
::
deserializer
*
source
,
U
*
x
)
->
decltype
(
x
->
serialize
(
*
source
),
std
::
true_type
());
template
<
class
>
static
auto
test_deserialize
(...)
->
std
::
false_type
;
using
serialize_type
=
decltype
(
test_serialize
<
T
>
(
nullptr
,
nullptr
));
using
deserialize_type
=
decltype
(
test_deserialize
<
T
>
(
nullptr
,
nullptr
));
using
type
=
std
::
integral_constant
<
bool
,
serialize_type
::
value
&&
deserialize_type
::
value
>
;
using
type
=
decltype
(
test
<
T
>
(
nullptr
,
nullptr
));
static
constexpr
bool
value
=
type
::
value
;
static
constexpr
bool
value
=
type
::
value
;
};
};
...
...
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