![]() |
Home | Libraries | People | FAQ | More |
#include <boost/callable_traits/function_type.hpp>
template<typename T> using function_type_t = //implementation-defined 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 = //implementation-defined 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_parent_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>
CALLABLE_TRAITS_NAMESPACE_BEGIN template<std::size_t I, typename T> using arg_at_t = //implementation-defined 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 = //implementation-defined 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/remove_args.hpp>
template<std::size_t Index, typename T, std::size_t Count = 1> using remove_args_t = //implementation-defined template<std::size_t Index, typename T, std::size_t Count = 1> struct remove_args { using type = remove_args_t<Index, T, Count>; };
T must be one of the
following:
Index must be less than
the number of types in the parameter list of T
Count must be less than
or equal to the number of types in the parameter list of T minus Index
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
T,
except that Count number
of types in the parameter list of T,
starting at zero-based Index,
do not exist in the parameter list of the aliased type.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
#include <type_traits> #include <boost/callable_traits/remove_args.hpp> namespace ct = boost::callable_traits; template<int I> struct N {}; struct foo {}; int main() { using f = int(foo::*)(N<0>, N<1>, N<2>, N<3>); using test = ct::remove_args_t<2, f>; using expect = int(foo::*)(N<0>, N<1>, N<3>); static_assert(std::is_same<test, expect>::value, ""); }
#include <boost/callable_traits/replace_args.hpp>
template<std::size_t Index, typename T, typename... Args> using replace_args_t = //implementation-defined template<std::size_t Index, typename T, typename... Args> struct replace_args { using type = replace_args_t<Index, T, Args...>; };
T must be one of the
following:
Index must be less than
the number of parameters in the parameter list of T
T,
except that the parameter list types are "overwritten" by
Args...,
beginning at zero-based Index.
sizeof...(Args)
is greater than then number of function parameters in T
minus Index, the aliased
type will contain more parameters than 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 <type_traits> #include <boost/callable_traits/replace_args.hpp> namespace ct = boost::callable_traits; template<int I> struct N {}; int main() { using f = int(&)(N<0>, N<1>, N<2>, N<3>); using test = ct::replace_args_t<2, f, int>; using expect = int(&)(N<0>, N<1>, int, N<3>); static_assert(std::is_same<test, expect>::value, ""); }
#include <boost/callable_traits/insert_args.hpp>
template<std::size_t Index, typename T, typename... Args> using insert_args_t = //implementation-defined template<std::size_t Index, typename T, typename... Args> struct insert_args { using type = insert_args_t<Index, T, Args...>; };
T must be one of the
following:
Index must be less than
or equal to the number of parameters in the parameter list of T
T,
except that Args...
are inserted into the parameter list of T,
at Index (zero-based).
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/insert_args.hpp> namespace ct = boost::callable_traits; template<int I> struct N {}; int main() { using f = int(*)(N<0>, N<1>, N<2>, N<3>); using test = ct::insert_args_t<1, f, int>; using expect = int(*)(N<0>, int, N<1>, N<2>, N<3>); static_assert(std::is_same<test, expect>::value, ""); }
#include <boost/callable_traits/pop_back_args.hpp>
template<typename T, std::size_t Count = 1> using pop_back_args_t = //implementation-defined template<typename T, std::size_t Count = 1> struct pop_back_args { using type = pop_back_args_t<T, Count>; };
T must be one of the
following:
T,
except that Count number
of parameters are removed from the back 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_back_args.hpp> namespace ct = boost::callable_traits; static_assert(std::is_same< ct::pop_back_args_t<int(char, short, int)>, int(char, short) >::value, ""); struct foo; static_assert(std::is_same< ct::pop_back_args_t<int(foo::*)(char, short, int), 2>, int(foo::*)(char) >::value, ""); static_assert(std::is_same< ct::pop_back_args_t<int(*)(char, short, int), 3>, int(*)() >::value, ""); static_assert(std::is_same< //underflow is handled ct::pop_back_args_t<int(&)(char, short, int), 27>, int(&)() >::value, ""); int main() {}
#include <boost/callable_traits/pop_front_args.hpp>
template<typename T, std::size_t Count = 1> using pop_front_args_t = //implementation-defined 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_back_args.hpp>
template<typename T, typename... Args> using push_back_args_t = //implementation-defined template<typename T, typename... Args> struct push_back_args { using type = push_back_args_t<T, Args...>; };
T must be one of the
following:
T,
except that Args...
types have been added to the back 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_back_args.hpp> namespace ct = boost::callable_traits; int main() { using f = void(int, char); using test = ct::push_back_args_t<f, long, void*>; using expect = void(int, char, long, void*); static_assert(std::is_same<test, expect>::value, ""); }
#include <boost/callable_traits/push_front_args.hpp>
template<typename T, typename... Args> using push_front_args_t = //implementation-defined 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 = //implementation-defined 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_parent_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.
Container cannot be
legally instantiated according to the behavior defined above with respect
to T, the behavior is
undefined.
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 = //implementation-defined 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....
Container cannot be
legally instantiated according to the behavior defined above with respect
to T and RightArgs...,
the behavior is undefined.
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 = //implementation-defined 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...).
Container cannot be
legally instantiated according to the behavior defined above with respect
to T and LeftArgs...,
the behavior is undefined.
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 = //implementation-defined 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 = //implementation-defined 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; //implementation-defined #ifdef CALLABLE_TRAITS_DISABLE_VARIABLE_TEMPLATES template<typename T> struct has_varargs_v { static_assert(sizeof(T) < 1, "Variable templates not supported on this compiler."); }; #else template<typename T> constexpr bool has_varargs_v = //implementation-defined #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() {}