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
72ea2a86
Commit
72ea2a86
authored
Jul 07, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use custom inspect overloads with high priority
parent
7f9eb366
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
9 deletions
+16
-9
libcaf_core/caf/detail/type_traits.hpp
libcaf_core/caf/detail/type_traits.hpp
+3
-0
libcaf_core/caf/read_inspector.hpp
libcaf_core/caf/read_inspector.hpp
+8
-6
libcaf_core/caf/write_inspector.hpp
libcaf_core/caf/write_inspector.hpp
+5
-3
No files found.
libcaf_core/caf/detail/type_traits.hpp
View file @
72ea2a86
...
@@ -590,6 +590,9 @@ struct is_same_ish
...
@@ -590,6 +590,9 @@ struct is_same_ish
template
<
class
>
template
<
class
>
struct
always_false
:
std
::
false_type
{};
struct
always_false
:
std
::
false_type
{};
template
<
class
T
>
constexpr
bool
always_false_v
=
always_false
<
T
>::
value
;
/// Utility trait for removing const inside a `map<K, V>::value_type`.
/// Utility trait for removing const inside a `map<K, V>::value_type`.
template
<
class
T
>
template
<
class
T
>
struct
deconst_kvp
{
struct
deconst_kvp
{
...
...
libcaf_core/caf/read_inspector.hpp
View file @
72ea2a86
...
@@ -97,6 +97,12 @@ private:
...
@@ -97,6 +97,12 @@ private:
using
squashed_type
=
detail
::
squashed_int_t
<
T
>
;
using
squashed_type
=
detail
::
squashed_int_t
<
T
>
;
auto
squashed_x
=
static_cast
<
squashed_type
>
(
x
);
auto
squashed_x
=
static_cast
<
squashed_type
>
(
x
);
CAF_READ_INSPECTOR_TRY
(
dref
.
apply
(
squashed_x
))
CAF_READ_INSPECTOR_TRY
(
dref
.
apply
(
squashed_x
))
}
else
if
constexpr
(
detail
::
is_inspectable
<
Subtype
,
T
>::
value
)
{
using
caf
::
detail
::
inspect
;
// We require that the implementation for `inspect` does not modify its
// arguments when passing a reading inspector.
auto
&
mutable_x
=
const_cast
<
T
&>
(
x
);
CAF_READ_INSPECTOR_TRY
(
inspect
(
dref
,
mutable_x
));
}
else
if
constexpr
(
detail
::
can_apply_v
<
Subtype
,
decltype
(
x
)
>
)
{
}
else
if
constexpr
(
detail
::
can_apply_v
<
Subtype
,
decltype
(
x
)
>
)
{
CAF_READ_INSPECTOR_TRY
(
dref
.
apply
(
x
))
CAF_READ_INSPECTOR_TRY
(
dref
.
apply
(
x
))
}
else
if
constexpr
(
std
::
is_array
<
T
>::
value
)
{
}
else
if
constexpr
(
std
::
is_array
<
T
>::
value
)
{
...
@@ -118,12 +124,8 @@ private:
...
@@ -118,12 +124,8 @@ private:
}
}
CAF_READ_INSPECTOR_TRY
(
dref
.
end_sequence
())
CAF_READ_INSPECTOR_TRY
(
dref
.
end_sequence
())
}
else
{
}
else
{
static_assert
(
detail
::
is_inspectable
<
Subtype
,
T
>::
value
);
static_assert
(
detail
::
always_false_v
<
T
>
,
using
caf
::
detail
::
inspect
;
"T is neither inspectable nor default-applicable"
);
// We require that the implementation for `inspect` does not modify its
// arguments when passing a reading inspector.
auto
&
mutable_x
=
const_cast
<
T
&>
(
x
);
CAF_READ_INSPECTOR_TRY
(
inspect
(
dref
,
mutable_x
));
}
}
return
true
;
return
true
;
}
}
...
...
libcaf_core/caf/write_inspector.hpp
View file @
72ea2a86
...
@@ -96,6 +96,9 @@ private:
...
@@ -96,6 +96,9 @@ private:
using
squashed_type
=
detail
::
squashed_int_t
<
T
>
;
using
squashed_type
=
detail
::
squashed_int_t
<
T
>
;
auto
&
squashed_x
=
reinterpret_cast
<
squashed_type
&>
(
x
);
auto
&
squashed_x
=
reinterpret_cast
<
squashed_type
&>
(
x
);
CAF_WRITE_INSPECTOR_TRY
(
dref
.
apply
(
squashed_x
))
CAF_WRITE_INSPECTOR_TRY
(
dref
.
apply
(
squashed_x
))
}
else
if
constexpr
(
detail
::
is_inspectable
<
Subtype
,
T
>::
value
)
{
using
caf
::
detail
::
inspect
;
CAF_WRITE_INSPECTOR_TRY
(
inspect
(
dref
,
x
));
}
else
if
constexpr
(
detail
::
can_apply_v
<
Subtype
,
decltype
(
x
)
>
)
{
}
else
if
constexpr
(
detail
::
can_apply_v
<
Subtype
,
decltype
(
x
)
>
)
{
CAF_WRITE_INSPECTOR_TRY
(
dref
.
apply
(
x
))
CAF_WRITE_INSPECTOR_TRY
(
dref
.
apply
(
x
))
}
else
if
constexpr
(
std
::
is_array
<
T
>::
value
)
{
}
else
if
constexpr
(
std
::
is_array
<
T
>::
value
)
{
...
@@ -126,9 +129,8 @@ private:
...
@@ -126,9 +129,8 @@ private:
}
}
CAF_WRITE_INSPECTOR_TRY
(
dref
.
end_sequence
())
CAF_WRITE_INSPECTOR_TRY
(
dref
.
end_sequence
())
}
else
{
}
else
{
static_assert
(
detail
::
is_inspectable
<
Subtype
,
T
>::
value
);
static_assert
(
detail
::
always_false_v
<
T
>
,
using
caf
::
detail
::
inspect
;
"T is neither inspectable nor default-applicable"
);
CAF_WRITE_INSPECTOR_TRY
(
inspect
(
dref
,
x
));
}
}
return
true
;
return
true
;
}
}
...
...
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