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
44127021
Commit
44127021
authored
Sep 24, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Specialize config_value_access for builtin types
parent
2b5b8b4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
8 deletions
+29
-8
libcaf_core/caf/config_value.hpp
libcaf_core/caf/config_value.hpp
+29
-8
No files found.
libcaf_core/caf/config_value.hpp
View file @
44127021
...
...
@@ -217,10 +217,39 @@ private:
// -- SumType-like access ------------------------------------------------------
template
<
class
T
>
struct
default_config_value_access
{
static
bool
is
(
const
config_value
&
x
)
{
return
holds_alternative
<
T
>
(
x
.
get_data
());
}
static
const
T
*
get_if
(
const
config_value
*
x
)
{
return
caf
::
get_if
<
T
>
(
&
(
x
->
get_data
()));
}
static
T
get
(
const
config_value
&
x
)
{
return
caf
::
get
<
T
>
(
x
.
get_data
());
}
};
/// @relates config_value
template
<
class
T
>
struct
config_value_access
;
#define CAF_DEFAULT_CONFIG_VALUE_ACCESS(type) \
template <> \
struct config_value_access<type> : default_config_value_access<type> {}
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
bool
);
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
double
);
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
atom_value
);
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
timespan
);
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
std
::
string
);
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
config_value
::
list
);
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
config_value
::
dictionary
);
#undef CAF_DEFAULT_CONFIG_VALUE_ACCESS
/// Delegates to config_value_access for all specialized versions.
template
<
class
T
,
bool
IsIntegral
=
std
::
is_integral
<
T
>
::
value
>
struct
select_config_value_access
{
...
...
@@ -328,8 +357,6 @@ struct sum_type_access<config_value> {
template
<
>
struct
config_value_access
<
float
>
{
static
constexpr
bool
specialized
=
true
;
static
bool
is
(
const
config_value
&
x
)
{
return
holds_alternative
<
double
>
(
x
.
get_data
());
}
...
...
@@ -353,8 +380,6 @@ template <class T>
struct
config_value_access
<
std
::
vector
<
T
>>
{
using
vector_type
=
std
::
vector
<
T
>
;
static
constexpr
bool
specialized
=
true
;
static
bool
is
(
const
config_value
&
x
)
{
auto
lst
=
caf
::
get_if
<
config_value
::
list
>
(
&
x
);
if
(
lst
!=
nullptr
)
{
...
...
@@ -396,8 +421,6 @@ template <class... Ts>
struct
config_value_access
<
std
::
tuple
<
Ts
...
>>
{
using
tuple_type
=
std
::
tuple
<
Ts
...
>
;
static
constexpr
bool
specialized
=
true
;
static
bool
is
(
const
config_value
&
x
)
{
if
(
auto
lst
=
caf
::
get_if
<
config_value
::
list
>
(
&
x
))
{
if
(
lst
->
size
()
!=
sizeof
...(
Ts
))
...
...
@@ -469,8 +492,6 @@ struct config_value_access<dictionary<V>> {
using
kvp
=
std
::
pair
<
const
std
::
string
,
config_value
>
;
static
constexpr
bool
specialized
=
true
;
static
bool
is
(
const
config_value
&
x
)
{
auto
lst
=
caf
::
get_if
<
config_value
::
dictionary
>
(
&
x
);
if
(
lst
!=
nullptr
)
{
...
...
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