KaMPIng 0.1.1
Flexible and (near) zero-overhead C++ bindings for MPI
|
Macros for generating concept-like type traits to check for member functions of objects. More...
#include <type_traits>
Go to the source code of this file.
Macros | |
#define | KAMPING_MAKE_HAS_MEMBER(Member) |
Macro for generating has_member_xxx and has_member_xxx_v templates. They return true if the type given as template parameter has a member (template) function provided name. | |
Macros for generating concept-like type traits to check for member functions of objects.
#define KAMPING_MAKE_HAS_MEMBER | ( | Member | ) |
Macro for generating has_member_xxx and has_member_xxx_v templates. They return true if the type given as template parameter has a member (template) function provided name.
If the function has no template parameters or they can be auto-deduced, use has_member_xxx::value
or has_member_xxx_v
, if not use has_member_xxx::value_with_template_params<...>
.
If the member function takes arguments, pass their types as additional template parameters to has_member_xxx
.
See the examples for details.
Example:
Explanation:
value
, the static member function test
is instantiated using the given type Type
.Type
and try to call the expected member function with instances of the passed MemberArgs
.test_with_template_params
also instantiates the functions template parameters with the passed types.decltype
, and cannot instantiate std::void_t<...>
, which fails to initialize the whole function test(int)
.test(long)
, which returns std::false_type
.std::true_type
.test
has int
and long
overloads to resolve ambiguity. Passing 0 to test
ensure that we first try to instantiate the true
variant.