![]() |
Home | Libraries | People | FAQ | More |
#include <boost/callable_traits/apply_member_pointer.hpp>
template<typename T, typename C> using apply_member_pointer_t = //see below template<typename T, typename C> struct apply_member_pointer { using type = apply_member_pointer_t<T, C>; };
T may be any type except
void
C must be a user-defined
type
T is a function,
function pointer, or function reference, then the aliased type is a member
function pointer of C
with the same parameters and return type.
T is a member function
pointer of any type, the aliased type is a member function pointer of
C with the same parameters
and return type.
std::remove_reference_t<T> C::*.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/apply_member_pointer.hpp> namespace ct = boost::callable_traits; struct foo; struct bar; int main() { { // function type -> member function pointer type using f = int(int); using g = ct::apply_member_pointer_t<f, foo>; using expect = int(foo::*)(int); static_assert(std::is_same<g, expect>::value, ""); } { // function pointer type (unqualified) -> member function pointer type using f = int(*)(); using g = ct::apply_member_pointer_t<f, foo>; using expect = int(foo::*)(); static_assert(std::is_same<g, expect>::value, ""); } { // function pointer type (qualified) -> member data pointer type // Look out for cases like these two. If the input type to apply_member_pointer // is a qualified function pointer type, then the aliased type is a member data // pointer to a qualified function pointer. { using f = int(*&)(); using g = ct::apply_member_pointer_t<f, foo>; using expect = int (* foo::*)(); static_assert(std::is_same<g, expect>::value, ""); } { using f = int(* const)(); using g = ct::apply_member_pointer_t<f, foo>; using expect = int (* const foo::*)(); static_assert(std::is_same<g, expect>::value, ""); } } { // function reference type -> member function pointer type using f = void(&)(); using g = ct::apply_member_pointer_t<f, foo>; using expect = void(foo::*)(); static_assert(std::is_same<g, expect>::value, ""); } { // member function pointer type -> member function pointer type // (note the different parent class) using f = int(bar::*)() const; using g = ct::apply_member_pointer_t<f, foo>; using expect = int(foo::*)() const; static_assert(std::is_same<g, expect>::value, ""); } { // non-callable type -> member data pointer type using g = ct::apply_member_pointer_t<int, foo>; using expect = int foo::*; static_assert(std::is_same<g, expect>::value, ""); } { // function object type -> member data pointer type // the same is true for lambdas and generic lambdas auto lambda = [](){}; using f = decltype(lambda); using g = ct::apply_member_pointer_t<f, foo>; using expect = f foo::*; static_assert(std::is_same<g, expect>::value, ""); } }
#include <boost/callable_traits/class_of.hpp>
template<typename T> using parent_class_of_t = //see below ======= Definitiontemplate<typename T> using class_of_t = //implementation-defined >>>>>>> 19a4484... rename parent_class_of to class_of template<typename T> struct class_of { using type = class_of_t<T>; };<<<<<<< HEAD Constraints ======= Constraints >>>>>>> 19a4484... rename parent_class_of to class_of
Tmust be a member pointer<<<<<<< HEAD Behavior ======= Behavior >>>>>>> 19a4484... rename parent_class_of to class_of
- A substitution failure occurs if the constraints are violated.
- The aliased type is the parent class of the member. In other words, if
Tis expanded toU C::*, the aliased type isC.<<<<<<< HEAD Compatibility ======= Compatibility >>>>>>> 19a4484... rename parent_class_of to class_of Notes
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
<<<<<<< HEAD Input/Output ======= Input/Output >>>>>>> 19a4484... rename parent_class_of to class_of Examples
T
class_of_t<T>
int foo::*
foo
void(foo::*)() const
foo<<<<<<< HEAD Example ======= Example >>>>>>> 19a4484... rename parent_class_of to class_of Program
#include <type_traits> #include <boost/callable_traits/class_of.hpp> namespace ct = boost::callable_traits; struct foo; static_assert(std::is_same<foo, ct::class_of_t<int(foo::*)()>>::value, ""); static_assert(std::is_same<foo, ct::class_of_t<int foo::*>>::value, ""); int main() {}
#include <boost/callable_traits/qualified_class_of.hpp>
template<typename T> using qualified_parent_class_of_t = //see below ======= Definitiontemplate<typename T> using qualified_class_of_t = //implementation-defined >>>>>>> 19a4484... rename parent_class_of to class_of template<typename T> struct qualified_class_of { using type = qualified_class_of_t<T>; };<<<<<<< HEAD Constraints ======= Constraints >>>>>>> 19a4484... rename parent_class_of to class_of
Tmust be a member pointer<<<<<<< HEAD Behavior ======= Behavior >>>>>>> 19a4484... rename parent_class_of to class_of
- A substitution failure occurs if the constraints are violated.
- If
Tis a member function pointer, the aliased type is the parent class of the member, qualified according to the member qualifiers onT. IfTdoes not have a member reference qualifier, then the aliased type will be an lvalue reference.- If
Tis a member data pointer, the aliased type is equivalent toct::class_of<T> const &.<<<<<<< HEAD Compatibility ======= Compatibility >>>>>>> 19a4484... rename parent_class_of to class_of Notes
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
<<<<<<< HEAD Input/Output ======= Input/Output >>>>>>> 19a4484... rename parent_class_of to class_of Examples
T
qualified_class_of_t<T>
void(foo::*)()
foo &
void(foo::*)() const
foo const &
void(foo::*)() &&
foo &&
void(foo::*)() volatile &&
foo volatile &&
int foo::*
foo const &
const int foo::*
foo const &<<<<<<< HEAD Example ======= Example >>>>>>> 19a4484... rename parent_class_of to class_of Program
#include <type_traits> #include <boost/callable_traits/qualified_class_of.hpp> namespace ct = boost::callable_traits; struct foo; static_assert(std::is_same<foo &, ct::qualified_class_of_t<int(foo::*)()>>::value, ""); static_assert(std::is_same<foo const &, ct::qualified_class_of_t<int(foo::*)() const>>::value, ""); static_assert(std::is_same<foo volatile &&, ct::qualified_class_of_t<int(foo::*)() volatile &&>>::value, ""); int main() {}