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
e09a83d8
Commit
e09a83d8
authored
Aug 02, 2016
by
Marian Triebe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `CAF_HAS_MEMBER_TRAIT` macro
parent
e47c5a49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
23 deletions
+15
-23
libcaf_core/caf/detail/type_traits.hpp
libcaf_core/caf/detail/type_traits.hpp
+15
-23
No files found.
libcaf_core/caf/detail/type_traits.hpp
View file @
e09a83d8
...
@@ -31,6 +31,19 @@
...
@@ -31,6 +31,19 @@
#include "caf/detail/type_list.hpp"
#include "caf/detail/type_list.hpp"
#define CAF_HAS_MEMBER_TRAIT(name) \
template <class T> \
struct has_##name##_member { \
template <class U> \
static auto test(U* x) -> decltype(x->name(), std::true_type()); \
\
template <class U> \
static auto test(...) -> std::false_type; \
\
using type = decltype(test<T>(nullptr)); \
static constexpr bool value = type::value; \
}
namespace
caf
{
namespace
caf
{
namespace
detail
{
namespace
detail
{
...
@@ -663,29 +676,8 @@ public:
...
@@ -663,29 +676,8 @@ public:
static
constexpr
bool
value
=
false
;
static
constexpr
bool
value
=
false
;
};
};
template
<
class
T
>
CAF_HAS_MEMBER_TRAIT
(
size
);
struct
has_data_member
{
CAF_HAS_MEMBER_TRAIT
(
data
);
template
<
class
U
>
static
auto
test
(
U
*
x
)
->
decltype
(
x
->
data
(),
std
::
true_type
());
template
<
class
U
>
static
auto
test
(...)
->
std
::
false_type
;
using
type
=
decltype
(
test
<
T
>
(
nullptr
));
static
constexpr
bool
value
=
type
::
value
;
};
template
<
class
T
>
struct
has_size_member
{
template
<
class
U
>
static
auto
test
(
U
*
x
)
->
decltype
(
x
->
size
(),
std
::
true_type
());
template
<
class
U
>
static
auto
test
(...)
->
std
::
false_type
;
using
type
=
decltype
(
test
<
T
>
(
nullptr
));
static
constexpr
bool
value
=
type
::
value
;
};
/// Checks whether T is convertible to either `std::function<void (T&)>`
/// Checks whether T is convertible to either `std::function<void (T&)>`
/// or `std::function<void (const T&)>`.
/// or `std::function<void (const T&)>`.
...
...
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