![]() |
Home | Libraries | People | FAQ | More |
#include <boost/callable_traits/function_type.hpp>
template<typename T> using function_type_t = //see below template<typename T> struct function_type { using type = function_type_t<T>; };
T must be one of the
following:
operator()
T is a function,
the aliased type is identical to T,
except that the aliased function type will not have member qualifiers
or the transaction_safe
specifier.
T is a function
pointer, the aliased type is equivalent to std::remove_pointer_t<T>.
T is a function
reference, the aliased type is equivalent to std::remove_reference_t<T>.
T is a function
object, the aliased type is a function type with the same return type
and parameter list as T's
operator().
T is a member function
pointer, the aliased type is a function type with the same return type
as T, and the first parameter
is a reference to the parent class of T,
qualified according to the member qualifiers on T.
The subsequent parameters, if any, are the parameter types of T.
T is a member data
pointer, the aliased type is a function type returning the underlying
member type of T, taking
a single parameter, which is a const
reference to the parent type of T.
transaction_safe
specifier.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits.hpp> namespace ct = boost::callable_traits; template<typename T> void test(){ // this example shows how boost::callable_traits::function_type_t // bevaves consistently for many different types using type = ct::function_type_t<T>; using expect = void(int, float&, const char*); static_assert(std::is_same<expect, type>{}, ""); } int main() { auto lamda = [](int, float&, const char*){}; using lam = decltype(lamda); test<lam>(); using function_ptr = void(*)(int, float&, const char*); test<function_ptr>(); using function_ref = void(&)(int, float&, const char*); test<function_ref>(); using function = void(int, float&, const char*); test<function>(); using abominable = void(int, float&, const char*) const; test<abominable>(); }
#include <boost/callable_traits/args.hpp>
template<typename T> using args_t = //see below template<typename T> struct args { using type = args_t<T>; };
T must be one of the
following:
operator()
T is a function,
function pointer, or function reference, the aliased type is a std::tuple whose element types match those
of the function's parameter list.
T is a function
object, the aliased type is a std::tuple
whose element types match those of the function object's operator()
parameter list.
T is a member function
pointer, the aliased type is a std::tuple
instantiation, where the first tuple element is a reference to the parent
class of T, qualified
according to the member qualifiers on T,
such that this first tuple element type is equivalent to boost::callable_traits::qualified_class_of_t<T>.
The subsequent template type arguments, if any, are the parameter types
of the member function.
T is a member data
pointer, the aliased type is a std::tuple
with a single element, which is a const
reference to the parent class of T.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <memory> #include <boost/callable_traits.hpp> namespace ct = boost::callable_traits; template<typename T, typename Expect> void test(){ using args_t = ct::args_t<T>; static_assert(std::is_same<args_t, Expect>::value, ""); } int main() { { auto lamda = [](int, float&, const char*){}; using lam = decltype(lamda); using expect = std::tuple<int, float&, const char*>; test<lam, expect>(); } { struct foo; using pmf = void(foo::*)(int, float&, const char*); using expect = std::tuple<foo&, int, float&, const char*>; test<pmf, expect>(); } { using function_ptr = void(*)(int, float&, const char*); using expect = std::tuple<int, float&, const char*>; test<function_ptr, expect>(); } { using function_ref = void(&)(int, float&, const char*); using expect = std::tuple<int, float&, const char*>; test<function_ref, expect>(); } { using function = void(int, float&, const char*); using expect = std::tuple<int, float&, const char*>; test<function, expect>(); } { using abominable = void(int, float&, const char*) const; using expect = std::tuple<int, float&, const char*>; test<abominable, expect>(); } }
#include <boost/callable_traits/arg_at.hpp>
BOOST_CLBL_TRTS_NAMESPACE_BEGIN template<std::size_t I, typename T> using arg_at_t = //see below template<std::size_t I, typename T> struct arg_at { using type = arg_at_t<I, T>; };
T must be one of the
following:
operator()
I must be less than
std::tuple_size<boost::callable_traits::args_t<T>>::value
arg_at_t<Index, T>
is equivalent to std::tuple_element_t<Index, boost::callable_traits::args_t<T>>.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
#include <type_traits> #include <boost/callable_traits/arg_at.hpp> namespace ct = boost::callable_traits; int main() { auto lambda = [](int, char, float){}; using lt = decltype(lambda); using second_param = ct::arg_at_t<1, lt>; static_assert(std::is_same<second_param, char>::value, ""); // With pointer-to-member functions, the implicit "this" pointer // is treated as the first parameter, in the form of a reference. using pmf = decltype(<::operator()); using object_ref = ct::arg_at_t<0, pmf>; static_assert(std::is_same<object_ref, lt const &>::value, ""); }
#include <boost/callable_traits/clear_args.hpp>
template<typename T> using clear_args_t = //see below template<typename T> struct clear_args { using type = clear_args_t<T>; };
T must be one of the
following:
T.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <boost/callable_traits/clear_args.hpp> namespace ct = boost::callable_traits; int main() { using f = void(int, char); using cleared = ct::clear_args_t<f>; using expect = void(); static_assert(std::is_same<cleared, expect>::value, ""); }
#include <boost/callable_traits/pop_front_args.hpp>
template<typename T, std::size_t Count = 1> using pop_front_args_t = //see below template<typename T, std::size_t Count = 1> struct pop_front_args { using type = pop_front_args_t<T, Count>; };
T must be one of the
following:
T,
except that Count number
of parameters are removed from the front of the parameter list.
Count is greater than
or equal to the number of parameters in T,
then the aliased type will have an empty parameter list.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
#include <boost/callable_traits/pop_front_args.hpp> namespace ct = boost::callable_traits; static_assert(std::is_same< ct::pop_front_args_t<int(char, short, int)>, int(short, int) >::value, ""); struct foo; static_assert(std::is_same< ct::pop_front_args_t<int(foo::*)(char, short, int) const, 2>, int(foo::*)(int) const >::value, ""); static_assert(std::is_same< ct::pop_front_args_t<int(*)(char, short, int), 3>, int(*)() >::value, ""); static_assert(std::is_same< //overflow is handled ct::pop_front_args_t<int(&)(char, short, int), 27>, int(&)() >::value, ""); int main() {}
#include <boost/callable_traits/push_front_args.hpp>
template<typename T, typename... Args> using push_front_args_t = //see below template<typename T, typename... Args> struct push_front_args { using type = push_front_args_t<T, Args...>; };
T must be one of the
following:
T,
except that Args...
types have been added to the front of the parameter list.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
#include <boost/callable_traits/push_front_args.hpp> namespace ct = boost::callable_traits; int main() { using f = void(int, char); using test = ct::push_front_args_t<f, long, void*>; using expect = void(long, void*, int, char); static_assert(std::is_same<test, expect>::value, ""); }
#include <boost/callable_traits/expand_args.hpp>
template<typename T, template<class...> class Container> using expand_args_t = //see below template<typename T, template<class...> class Container> struct expand_args { using type = expand_args_t<T, Container>; };
T must be one of the
following:
operator()
T is a function,
function pointer, or function reference, the aliased type is the Container template instantiated with
the types from the parameter list of T.
T is a function
object, the aliased type is the Container
template instantiated with the types from the parameter list of T's operator().
T is a member function
pointer, the aliased type is a Container
template instantiation, where the first template type argument is a reference
to the parent class of T,
qualified according to the member qualifiers on T,
such that this type is equivalent to boost::callable_traits::qualified_class_of_t<T>. The subsequent template type arguments
are the parameter list of the member function.
T is a member data
pointer, the aliased type is the Container
template instantiated with a const
reference to the parent class of T.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <boost/callable_traits/expand_args.hpp> namespace ct = boost::callable_traits; void f(int, char); template<typename, typename> struct foo{}; int main() { using args = ct::expand_args_t<decltype(f), foo>; static_assert(std::is_same<args, foo<int, char>>::value, ""); }
#include <boost/callable_traits/expand_args_left.hpp>
template<typename T, template<class...> class Container, typename... RightArgs> using expand_args_left_t = //see below template<typename T, template<class...> class Container, typename... RightArgs> struct expand_args_left { using type = expand_args_left_t<T, Container, RightArgs...>; };
T must be one of the
following:
operator()
expand_args_left is identical
to expand_args, except
that additional type arguments for Container
may be supplied. the types determined by T
are expanded first (on the left), followed
by the supplied RightArgs....
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <boost/callable_traits/expand_args_left.hpp> namespace ct = boost::callable_traits; void f(int, char); template<typename...> struct foo{}; int main() { using args = ct::expand_args_left_t<decltype(f), foo, void*>; static_assert(std::is_same<args, foo<int, char, void*>>::value, ""); }
#include <boost/callable_traits/expand_args_right.hpp>
template<typename T, template<class...> class Container, typename... LeftArgs> using expand_args_right_t = //see below template<typename T, template<class...> class Container, typename... LeftArgs> struct expand_args_right { using type = expand_args_right_t<T, Container, LeftArgs...>; };
T must be one of the
following:
operator()
expand_args_right is
identical to expand_args,
except that additional type arguments for Container
may be supplied, which are expanded into the Container
template first. The types determined by T
are expanded last (to the right of the
supplied LeftArgs...).
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <boost/callable_traits/expand_args_right.hpp> namespace ct = boost::callable_traits; void f(int, char); template<typename...> struct foo{}; int main() { using args = ct::expand_args_right_t<decltype(f), foo, void*>; static_assert(std::is_same<args, foo<void*, int, char>>::value, ""); }
#include <boost/callable_traits/add_varargs.hpp>
template<typename T> using add_varargs_t = //see below template<typename T> struct add_varargs { using type = add_varargs_t<T>; };
T must be one of the
following:
...)
to the signature of T,
if not already present.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/add_varargs.hpp> namespace ct = boost::callable_traits; struct foo {}; int main() { { using f = void(int); using expect = void(int, ...); using test = ct::add_varargs_t<f>; static_assert(std::is_same<test, expect>::value, ""); } { using fp = void(*)(); using expect = void(*)(...); using test = ct::add_varargs_t<fp>; static_assert(std::is_same<test, expect>::value, ""); } { using fr = void(&)(const char*); using expect = void(&)(const char*, ...); using test = ct::add_varargs_t<fr>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = void(foo::*)() const; using expect = void(foo::*)(...) const; using test = ct::add_varargs_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); // add_varargs_t doesn't change anything when // the type already has varargs. using twice = ct::add_varargs_t<test>; static_assert(std::is_same<test, twice>::value, ""); } }
#include <boost/callable_traits/remove_varargs.hpp>
template<typename T> using remove_varargs_t = //see below template<typename T> struct remove_varargs { using type = remove_varargs_t<T>; };
T must be one of the
following:
...)
from the signature of T,
if present.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/remove_varargs.hpp> namespace ct = boost::callable_traits; struct foo {}; int main() { { using f = void(int, ...); using expect = void(int); using test = ct::remove_varargs_t<f>; static_assert(std::is_same<test, expect>::value, ""); } { using fp = void(*)(...); using expect = void(*)(); using test = ct::remove_varargs_t<fp>; static_assert(std::is_same<test, expect>::value, ""); } { using fr = void(&)(const char*, ...); using expect = void(&)(const char*); using test = ct::remove_varargs_t<fr>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = void(foo::*)(...) const; using expect = void(foo::*)() const; using test = ct::remove_varargs_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } }
#include <boost/callable_traits/has_varargs.hpp>
template<typename T> struct has_varargs; //see below #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES template<typename T> struct has_varargs_v { static_assert(std::is_same<T, detail::dummy>::value, "Variable templates not supported on this compiler."); }; #else template<typename T> constexpr bool has_varargs_v = //see below #endif
std::false_type is inherited by has_varargs<T>
and is aliased by typename has_varargs<T>::type, except when one of the following
criteria is met, in which case std::true_type
would be similarly inherited and aliased:
T is a function,
function pointer, or function reference where the function's parameter
list includes C-style variadics.
T is a pointer
to a member function with C-style variadics in the parameter list.
T is a function
object with a non-overloaded operator(), which has C-style variadics
in the parameter list of its operator().
has_varargs_v<T> is equivalent to has_varargs<T>::value.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <type_traits> #include <boost/callable_traits/has_varargs.hpp> namespace ct = boost::callable_traits; static_assert(ct::has_varargs<int(...)>::value, ""); static_assert(!ct::has_varargs<int()>::value, ""); int main() {}