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
69f75141
Commit
69f75141
authored
Jun 06, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix type mismatches in data processor
parent
084ec5f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
3 deletions
+95
-3
libcaf_core/caf/data_processor.hpp
libcaf_core/caf/data_processor.hpp
+21
-3
libcaf_core/caf/detail/select_integer_type.hpp
libcaf_core/caf/detail/select_integer_type.hpp
+74
-0
No files found.
libcaf_core/caf/data_processor.hpp
View file @
69f75141
...
@@ -32,9 +32,11 @@
...
@@ -32,9 +32,11 @@
#include "caf/detail/type_list.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/detail/apply_args.hpp"
#include "caf/detail/apply_args.hpp"
#include "caf/detail/delegate_serialize.hpp"
#include "caf/detail/delegate_serialize.hpp"
#include "caf/detail/select_integer_type.hpp"
namespace
caf
{
namespace
caf
{
/// A data processor translates an object into a format that can be
/// A data processor translates an object into a format that can be
/// stored or vice versa. A data processor can be either in saving
/// stored or vice versa. A data processor can be either in saving
/// or loading mode.
/// or loading mode.
...
@@ -111,10 +113,26 @@ public:
...
@@ -111,10 +113,26 @@ public:
/// Applies this processor to an arithmetic type.
/// Applies this processor to an arithmetic type.
template
<
class
T
>
template
<
class
T
>
typename
std
::
enable_if
<
std
::
is_arithmetic
<
T
>::
value
>::
type
typename
std
::
enable_if
<
std
::
is_floating_point
<
T
>::
value
>::
type
apply
(
T
&
x
)
{
static
constexpr
auto
tlindex
=
detail
::
tl_index_of
<
builtin_t
,
T
>::
value
;
static_assert
(
tlindex
>=
0
,
"T not recognized as builtiln type"
);
apply_builtin
(
static_cast
<
builtin
>
(
tlindex
),
&
x
);
}
template
<
class
T
>
typename
std
::
enable_if
<
std
::
is_integral
<
T
>::
value
&&
!
std
::
is_same
<
bool
,
T
>::
value
>::
type
apply
(
T
&
x
)
{
apply
(
T
&
x
)
{
apply_builtin
(
static_cast
<
builtin
>
(
detail
::
tl_index_of
<
builtin_t
,
T
>::
value
),
using
type
=
&
x
);
typename
detail
::
select_integer_type
<
static_cast
<
int
>
(
sizeof
(
T
))
*
(
std
::
is_signed
<
T
>::
value
?
-
1
:
1
)
>::
type
;
static
constexpr
auto
tlindex
=
detail
::
tl_index_of
<
builtin_t
,
type
>::
value
;
static_assert
(
tlindex
>=
0
,
"T not recognized as builtiln type"
);
apply_builtin
(
static_cast
<
builtin
>
(
tlindex
),
&
x
);
}
}
void
apply
(
std
::
string
&
x
)
{
void
apply
(
std
::
string
&
x
)
{
...
...
libcaf_core/caf/detail/select_integer_type.hpp
0 → 100644
View file @
69f75141
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2015 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_DETAIL_SELECT_INTEGER_TYPE_HPP
#define CAF_DETAIL_SELECT_INTEGER_TYPE_HPP
#include <cstdint>
namespace
caf
{
namespace
detail
{
template
<
int
>
struct
select_integer_type
;
template
<
>
struct
select_integer_type
<-
1
>
{
using
type
=
int8_t
;
};
template
<
>
struct
select_integer_type
<
1
>
{
using
type
=
uint8_t
;
};
template
<
>
struct
select_integer_type
<-
2
>
{
using
type
=
int16_t
;
};
template
<
>
struct
select_integer_type
<
2
>
{
using
type
=
uint16_t
;
};
template
<
>
struct
select_integer_type
<-
4
>
{
using
type
=
int32_t
;
};
template
<
>
struct
select_integer_type
<
4
>
{
using
type
=
uint32_t
;
};
template
<
>
struct
select_integer_type
<-
8
>
{
using
type
=
int64_t
;
};
template
<
>
struct
select_integer_type
<
8
>
{
using
type
=
uint64_t
;
};
}
// namespace detail
}
// namespace caf
#endif // CAF_DETAIL_SELECT_INTEGER_TYPE_HPP
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