Boost
C++ Libraries
...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
This is an older version of Boost and was released in 2024. The current version is 1.90.0.
This reference will be most beneficial to readers familiar with the following C++ topics:
INVOKE
rules
operator()
#include <boost/callable_traits/add_member_const.hpp>
template<typename T> using add_member_const_t = //see below template<typename T> struct add_member_const : detail::add_member_const_impl<T> {};
T must be a function
type or a member function pointer type
T is a pointer, it
may not be cv/ref qualified
const qualifier
to T, if not already
present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/add_member_const.hpp> namespace ct = boost::callable_traits; struct foo {}; int main() { { using pmf = int(foo::*)(); using expect = int(foo::*)() const; using test = ct::add_member_const_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { // add_member_const_t doesn't change anything when // the function type is already const. using pmf = int(foo::*)() const &&; using expect = int(foo::*)() const &&; using test = ct::add_member_const_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = int(foo::*)() volatile &; using expect = int(foo::*)() const volatile &; using test = ct::add_member_const_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { // add_member_const_t can also be used with "abominable" // function types. using f = int(); using expect = int() const; using test = ct::add_member_const_t<f>; static_assert(std::is_same<test, expect>::value, ""); } }
#include <boost/callable_traits/add_member_cv.hpp>
template<typename T> using add_member_cv_t = //see below template<typename T> struct add_member_cv : detail::add_member_cv_impl<T> {};
T must be a function
type or a member function pointer type
T is a pointer, it
may not be cv/ref qualified
const and volatile qualifiers to T,
if not already present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/add_member_cv.hpp> namespace ct = boost::callable_traits; struct foo {}; int main() { { using pmf = void(foo::*)(); using expect = void(foo::*)() const volatile; using test = ct::add_member_cv_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { // add_member_cv_t doesn't change anything when // the function type is already cv-qualified. using pmf = void(foo::*)() const volatile &&; using expect = void(foo::*)() const volatile &&; using test = ct::add_member_cv_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = void(foo::*)() volatile &; using expect = void(foo::*)() const volatile &; using test = ct::add_member_cv_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { // add_member_cv_t can also be used with "abominable" // function types. using f = void(); using expect = void() const volatile; using test = ct::add_member_cv_t<f>; static_assert(std::is_same<test, expect>::value, ""); } }
#include <boost/callable_traits/add_member_lvalue_reference.hpp>
template<typename T> using add_member_lvalue_reference_t = //see below template<typename T> struct add_member_lvalue_reference : detail::add_member_lvalue_reference_impl<T> {};
T must be a function
type or a member function pointer type
T is a pointer, it
may not be cv/ref qualified
&)
to T, if not already
present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/add_member_lvalue_reference.hpp> namespace ct = boost::callable_traits; struct foo {}; int main() { { using pmf = void(foo::*)(); using expect = void(foo::*)() &; using test = ct::add_member_lvalue_reference_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { // add_member_lvalue_reference_t doesn't change anything when // the function type already has an lvalue qualifier. using pmf = void(foo::*)() &; using expect = void(foo::*)() &; using test = ct::add_member_lvalue_reference_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { // add_member_lvalue_reference_t models C++11 reference collapsing // rules, so that adding an lvalue qualifier to an // rvalue-qualified type will force the lvalue. using pmf = void(foo::*)() &&; using expect = void(foo::*)() &; using test = ct::add_member_lvalue_reference_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { // add_member_lvalue_reference_t can also be used to create "abominable" // function types. using f = void(); using expect = void() &; using test = ct::add_member_lvalue_reference_t<f>; static_assert(std::is_same<test, expect>::value, ""); } }
#include <boost/callable_traits/add_member_rvalue_reference.hpp>
template<typename T> using add_member_rvalue_reference_t = //see below template<typename T> struct add_member_rvalue_reference : detail::add_member_rvalue_reference_impl<T> {};
T must be a function
type or a member function pointer type
T is a pointer, it
may not be cv/ref qualified
&&)
to T, if not already
present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/add_member_rvalue_reference.hpp> namespace ct = boost::callable_traits; struct foo {}; int main() { { using pmf = void(foo::*)(); using expect = void(foo::*)() &&; using test = ct::add_member_rvalue_reference_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { // add_member_rvalue_reference_t doesn't change anything when // the function type already has an rvalue qualifier. using pmf = void(foo::*)() &&; using expect = void(foo::*)() &&; using test = ct::add_member_rvalue_reference_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { // add_member_rvalue_reference_t models C++11 reference collapsing // rules, so that adding an rvalue qualifier to an // lvalue-qualified type will not change anything. using pmf = void(foo::*)() const &; using expect = void(foo::*)() const &; using test = ct::add_member_rvalue_reference_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { // add_member_rvalue_reference_t can also be used with "abominable" // function types. using f = void() const; using expect = void() const &&; using test = ct::add_member_rvalue_reference_t<f>; static_assert(std::is_same<test, expect>::value, ""); } }
#include <boost/callable_traits/add_member_volatile.hpp>
template<typename T> using add_member_volatile_t = //see below template<typename T> struct add_member_volatile : detail::add_member_volatile_impl<T> {};
T must be a function
type or a member function pointer type
T is a pointer, it
may not be cv/ref qualified
T,
if not already present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/add_member_volatile.hpp> namespace ct = boost::callable_traits; struct foo {}; int main() { { using pmf = void(foo::*)(); using expect = void(foo::*)() volatile; using test = ct::add_member_volatile_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { // add_member_volatile_t doesn't change anything when // the function type is already volatile. using pmf = void(foo::*)() volatile &&; using expect = void(foo::*)() volatile &&; using test = ct::add_member_volatile_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = void(foo::*)() const &; using expect = void(foo::*)() const volatile &; using test = ct::add_member_volatile_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { // add_member_volatile_t can also be used with "abominable" // function types. using f = void(); using expect = void() volatile; using test = ct::add_member_volatile_t<f>; static_assert(std::is_same<test, expect>::value, ""); } }
#include <boost/callable_traits/add_noexcept.hpp>
template<typename T> using add_noexcept_t = //see below template<typename T> struct add_noexcept : detail::add_noexcept_impl<T> {};
T must be one of the
following:
T is a pointer, it
may not be cv/ref qualified
noexcept specifier
to T, if not already
present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/add_noexcept.hpp> using boost::callable_traits::add_noexcept_t; static_assert(std::is_same< add_noexcept_t<int()>, int() noexcept >{}, ""); int main() {}
#include <boost/callable_traits/add_transaction_safe.hpp>
template<typename T> using add_transaction_safe_t = //see below template<typename T> struct add_transaction_safe : detail::add_transaction_safe_impl<T> {};
T must be one of the
following:
T is a pointer, it
may not be cv/ref qualified
transaction_safe
specifier to T, if not
already present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/add_transaction_safe.hpp> using boost::callable_traits::add_transaction_safe_t; using not_safe = int(); using safe = int() transaction_safe; using safe_added = add_transaction_safe_t<not_safe>; static_assert(std::is_same<safe, safe_added>{}, ""); int main() {}
#include <boost/callable_traits/add_varargs.hpp>
template<typename T> using add_varargs_t = //see below template<typename T> struct add_varargs : detail::add_varargs_impl<T> {};
T must be one of the
following:
T is a pointer, it
may not be cv/ref qualified
...)
to the signature of T,
if not already present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(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/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 : detail::apply_member_pointer_impl<T, C> {};
T may be any type except
void
C must be a user-defined
type
T is a function,
function pointer (unqualified), 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 (unqualified) 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::*.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(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/apply_return.hpp>
template<typename T, typename R> using apply_return_t = //see below template<typename T, typename R> struct apply_return : detail::apply_return_impl<T, R> {};
T must one of the following:
std::tuple template instantiation
T is a pointer, it
may not be cv/ref qualified
T is std::tuple<Args...>,
the aliased type is R(Args...).
T is a function,
function pointer, function reference, or member function pointer, the
aliased type's return type is R,
but is otherwise identical to T.
T is a member data
pointer of class foo
to a U type (such that
T is U
foo::*),
the aliased type is R foo::*.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
[apply_return]
#include <boost/callable_traits/args.hpp>
template<typename T, template<class...> class Container = std::tuple> using args_t = //see below template<typename T, template<class...> class Container = std::tuple> struct args : detail::args_impl<T, Container> {};
T must be one of the
following:
operator()
T is a function,
function pointer, or function reference, the aliased type is Container instantiated with the function's
parameter types.
T is a function
object, the aliased type is Container
instantiated with the T::operator() parameter types.
T is a member function
pointer, the aliased type is a Container
instantiation, where the first type argument is a reference to the parent
class of T, qualified
according to the member qualifiers on T,
such that the first type is equivalent to boost::callable_traits::qualified_class_of_t<T>. The subsequent type arguments, if
any, are the parameter types of the member function.
T is a member data
pointer, the aliased type is Container
with a single element, which is a const
reference to the parent class of T.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(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/class_of.hpp>
template<typename T> using class_of_t = //see below template<typename T> struct class_of : detail::class_of_impl<T> {};
T must be a member pointer
T is expanded to U C::*, the aliased type is C.
|
|
|
|---|---|
|
|
|
|
|
|
#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/function_type.hpp>
template<typename T> using function_type_t = //see below template<typename T> struct function_type : detail::function_type_impl<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.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(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/has_member_qualifiers.hpp>
// inherits from either std::true_type or std::false_type template<typename T> struct has_member_qualifiers; // only available when variable templates are supported template<typename T> constexpr bool has_member_qualifiers_v = //see below
std::false_type is inherited by has_member_qualifiers<T>
and is aliased by typename has_member_qualifiers<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
with member qualifiers
T is a member function
pointer with member qualifiers
T is a function
object with a member-qualified operator()
has_member_qualifiers_v<T> is equivalent to has_member_qualifiers<T>::value.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <type_traits> #include <boost/callable_traits/has_member_qualifiers.hpp> namespace ct = boost::callable_traits; struct foo; static_assert(ct::has_member_qualifiers<int(foo::*)() const>::value, ""); static_assert(ct::has_member_qualifiers<int(foo::*)() volatile>::value, ""); static_assert(!ct::has_member_qualifiers<int(foo::*)()>::value, ""); int main() {}
#include <boost/callable_traits/has_varargs.hpp>
// inherits from either std::true_type or std::false_type template<typename T> struct has_varargs; // only available when variable templates are supported template<typename T> constexpr bool has_varargs_v = //see below
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.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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() {}
#include <boost/callable_traits/has_void_return.hpp>
// inherits from either std::true_type or std::false_type template<typename T> struct has_void_return; // only available when variable templates are supported template<typename T> constexpr bool has_void_return_v = //see below
std::false_type is inherited by has_void_return<T>
and is aliased by typename has_void_return<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 return
type is void.
T is a pointer
to a member function whose return type is void.
T is a function
object with a non-overloaded operator(), where the operator() function returns void.
has_void_return_v<T> is equivalent to has_void_return<T>::value.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <type_traits> #include <boost/callable_traits/has_void_return.hpp> namespace ct = boost::callable_traits; static_assert(ct::has_void_return<void()>::value, ""); static_assert(!ct::has_void_return<int()>::value, ""); int main() {}
#include <boost/callable_traits/is_const_member.hpp>
// inherits from either std::true_type or std::false_type template<typename T> struct is_const_member; // only available when variable templates are supported template<typename T> constexpr bool is_const_member_v = //see below
is_const_member<T>::value is true
when either:
T is a function
type with a const
member qualifier
T is a pointer
to a member function with a const
member qualifier
T is a function
object with a non-overloaded operator(), where the operator() has a const
member qualifier
is_const_member_v<T> is equivalent to is_const_member<T>::value.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <type_traits> #include <boost/callable_traits/is_const_member.hpp> namespace ct = boost::callable_traits; struct foo; static_assert(ct::is_const_member<int(foo::*)() const>::value, ""); static_assert(!ct::is_const_member<int(foo::*)()>::value, ""); int main() {}
#include <boost/callable_traits/is_cv_member.hpp>
// inherits from either std::true_type or std::false_type template<typename T> struct is_cv_member; // only available when variable templates are supported template<typename T> constexpr bool is_cv_member_v = //see below
is_cv_member<T>::value is true
when either:
T is a function
type with both const
and volatile member
qualifiers
T is a pointer
to a member function with both const
and volatile member
qualifiers
T is a function
object with a non-overloaded operator(), where the operator() has both const
and volatile member
qualifiers
is_cv_member_v<T> is equivalent to is_cv_member<T>::value.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <type_traits> #include <boost/callable_traits/is_cv_member.hpp> namespace ct = boost::callable_traits; struct foo; static_assert(ct::is_cv_member<int(foo::*)() const volatile>::value, ""); static_assert(!ct::is_cv_member<int(foo::*)()>::value, ""); static_assert(!ct::is_cv_member<int(foo::*)() const>::value, ""); static_assert(!ct::is_cv_member<int(foo::*)() volatile>::value, ""); int main() {}
#include <boost/callable_traits/is_invocable.hpp>
// inherits from either std::true_type or std::false_type template<typename T, typename... Args> struct is_invocable; // inherits from either std::true_type or std::false_type template<typename Ret, typename T, typename... Args> struct is_invocable_r; // only available when variable templates are supported template<typename T, typename... Args> constexpr bool is_invocable_v = //see below // only available when variable templates are supported template<typename Ret, typename T, typename... Args> constexpr bool is_invocable_r_v = //see below
standalone c++11 implementation of c++17 std::is_invocable,
std::is_invocable_r
![]() |
Note |
|---|---|
ref-qualified overloads of |
#include <type_traits> #include <boost/callable_traits/is_invocable.hpp> namespace ct = boost::callable_traits; struct foo { template<typename T> typename std::enable_if<std::is_integral<T>::value>::type operator()(T){} }; static_assert(ct::is_invocable<foo, int>::value, ""); static_assert(!ct::is_invocable<foo, double>::value, ""); int main() {}
#include <boost/callable_traits/is_lvalue_reference_member.hpp>
// inherits from either std::true_type or std::false_type template<typename T> struct is_lvalue_reference_member; // only available when variable templates are supported template<typename T> constexpr bool is_lvalue_reference_member_v = //see below
is_lvalue_reference_member<T>::value
is true when either:
T is a function
type with a '&' member qualifier
T is a pointer
to a member function with a '&' member qualifiers
T is a function
object with a non-overloaded operator(), where the operator() has a '&' member qualifier
is_lvalue_reference_member_v<T> is equivalent to is_lvalue_reference_member<T>::value.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <type_traits> #include <boost/callable_traits/is_lvalue_reference_member.hpp> namespace ct = boost::callable_traits; static_assert(ct::is_lvalue_reference_member<int()&>::value, ""); static_assert(!ct::is_lvalue_reference_member<int()&&>::value, ""); static_assert(!ct::is_lvalue_reference_member<int()>::value, ""); struct foo; static_assert(ct::is_lvalue_reference_member<int(foo::*)()&>::value, ""); static_assert(!ct::is_lvalue_reference_member<int(foo::*)()&&>::value, ""); static_assert(!ct::is_lvalue_reference_member<int(foo::*)()>::value, ""); int main() {}
#include <boost/callable_traits/is_reference_member.hpp>
// inherits from either std::true_type or std::false_type template<typename T> struct is_reference_member; // only available when variable templates are supported template<typename T> constexpr bool is_reference_member_v = //see below
is_reference_member<T>::value is true
when either:
T is a function
type with a '&' or '&&' member qualifier
T is a pointer
to a member function with a '&' or '&&' member qualifiers
T is a function
object with a non-overloaded operator(), where the operator() has a '&' or '&&'
member qualifier
is_reference_member_v<T> is equivalent to is_reference_member<T>::value.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <type_traits> #include <boost/callable_traits/is_reference_member.hpp> namespace ct = boost::callable_traits; static_assert(ct::is_reference_member<int()&>::value, ""); static_assert(ct::is_reference_member<int()&&>::value, ""); static_assert(!ct::is_reference_member<int()>::value, ""); struct foo; static_assert(ct::is_reference_member<int(foo::*)()&>::value, ""); static_assert(ct::is_reference_member<int(foo::*)()&&>::value, ""); static_assert(!ct::is_reference_member<int(foo::*)()>::value, ""); int main() {}
#include <boost/callable_traits/is_rvalue_reference_member.hpp>
// inherits from either std::true_type or std::false_type template<typename T> struct is_rvalue_reference_member; // only available when variable templates are supported template<typename T> constexpr bool is_rvalue_reference_member_v = //see below
is_rvalue_reference_member<T>::value
is true when either:
T is a function
type with a '&&' member qualifier
T is a pointer
to a member function with a '&&' member qualifiers
T is a function
object with a non-overloaded operator(), where the operator() has a '&&' member qualifier
is_rvalue_reference_member_v<T> is equivalent to is_rvalue_reference_member<T>::value.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <type_traits> #include <boost/callable_traits/is_rvalue_reference_member.hpp> namespace ct = boost::callable_traits; static_assert(ct::is_rvalue_reference_member<int()&&>::value, ""); static_assert(!ct::is_rvalue_reference_member<int()&>::value, ""); static_assert(!ct::is_rvalue_reference_member<int()>::value, ""); struct foo; static_assert(ct::is_rvalue_reference_member<int(foo::*)()&&>::value, ""); static_assert(!ct::is_rvalue_reference_member<int(foo::*)()&>::value, ""); static_assert(!ct::is_rvalue_reference_member<int(foo::*)()>::value, ""); int main() {}
#include <boost/callable_traits/is_noexcept.hpp>
// inherits from either std::true_type or std::false_type template<typename T> struct is_noexcept; // only available when variable templates are supported template<typename T> constexpr bool is_noexcept_v = //see below
is_noexcept<T>::value is true
when either:
T is a function
type, function pointer type, function reference type, or member
function pointer type where the function has a noexcept
specifier
T is a function
object with a non-overloaded operator(), where the operator() has a noexcept
specifier
is_noexcept_v<T> is equivalent to is_noexcept<T>::value.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <boost/callable_traits/is_noexcept.hpp> namespace ct = boost::callable_traits; struct foo; static_assert(ct::is_noexcept<int() noexcept>::value, ""); static_assert(ct::is_noexcept<int(*)() noexcept>::value, ""); static_assert(ct::is_noexcept<int(&)() noexcept>::value, ""); static_assert(ct::is_noexcept<int(foo::*)() const noexcept>::value, ""); static_assert(!ct::is_noexcept<int()>::value, ""); static_assert(!ct::is_noexcept<int(*)()>::value, ""); static_assert(!ct::is_noexcept<int(&)()>::value, ""); static_assert(!ct::is_noexcept<int(foo::*)() const>::value, ""); int main() {}
#include <boost/callable_traits/is_transaction_safe.hpp>
// inherits from either std::true_type or std::false_type template<typename T> struct is_transaction_safe; // only available when variable templates are supported template<typename T> constexpr bool is_transaction_safe_v = //see below
is_transaction_safe<T>::value is true
when either:
T is a function
type, function pointer type, function reference type, or member
function pointer type where the function has a transaction_safe
specifier
T is a function
object with a non-overloaded operator(), where the operator() has a transaction_safe
specifier
is_transaction_safe_v<T> is equivalent to is_transaction_safe<T>::value.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <boost/callable_traits/is_transaction_safe.hpp> namespace ct = boost::callable_traits; struct foo; static_assert(ct::is_transaction_safe<int() transaction_safe>::value, ""); static_assert(ct::is_transaction_safe<int(*)() transaction_safe>::value, ""); static_assert(ct::is_transaction_safe<int(&)() transaction_safe>::value, ""); static_assert(ct::is_transaction_safe<int(foo::*)() const transaction_safe>::value, ""); static_assert(!ct::is_transaction_safe<int()>::value, ""); static_assert(!ct::is_transaction_safe<int(*)()>::value, ""); static_assert(!ct::is_transaction_safe<int(&)()>::value, ""); static_assert(!ct::is_transaction_safe<int(foo::*)() const>::value, ""); int main() {}
#include <boost/callable_traits/is_volatile_member.hpp>
// inherits from either std::true_type or std::false_type template<typename T> struct is_volatile_member; // only available when variable templates are supported template<typename T> constexpr bool is_volatile_member_v = //see below
is_volatile_member<T>::value is true
when either:
T is a function
type with a volatile
member qualifier
T is a pointer
to a member function with a volatile
member qualifier
T is a function
object with a non-overloaded operator(), where the operator() has a volatile
member qualifier
is_volatile_member_v<T> is equivalent to is_volatile_member<T>::value.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <type_traits> #include <boost/callable_traits/is_volatile_member.hpp> namespace ct = boost::callable_traits; static_assert(ct::is_volatile_member<int() volatile>::value, ""); static_assert(ct::is_volatile_member<int() const volatile>::value, ""); static_assert(!ct::is_volatile_member<int()>::value, ""); struct foo; static_assert(ct::is_volatile_member<int(foo::*)() volatile>::value, ""); static_assert(!ct::is_volatile_member<int(foo::*)() const>::value, ""); static_assert(!ct::is_volatile_member<int(foo::*)()>::value, ""); int main() {}
#include <boost/callable_traits/qualified_class_of.hpp>
template<typename T> using qualified_class_of_t = //see below template<typename T> struct qualified_class_of : detail::qualified_class_of_impl<T> {};
T must be a member pointer
T is a member function
pointer, the aliased type is the parent class of the member, qualified
according to the member qualifiers on T.
If T does not have a
member reference qualifier, then the aliased type will be an lvalue reference.
T is a member data
pointer, the aliased type is equivalent to ct::class_of<T> const &.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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() {}
#include <boost/callable_traits/remove_member_const.hpp>
template<typename T> using remove_member_const_t = //see below template<typename T> struct remove_member_const : detail::remove_member_const_impl<T> {};
T must be a function
type or a member function pointer type
T is a pointer, it
may not be cv/ref qualified
const
qualifier from T, if
present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/remove_member_const.hpp> namespace ct = boost::callable_traits; struct foo {}; int main() { { using pmf = int(foo::*)() const; using expect = int(foo::*)(); using test = ct::remove_member_const_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = int(foo::*)() const &&; using expect = int(foo::*)() &&; using test = ct::remove_member_const_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = int(foo::*)() const volatile &; using expect = int(foo::*)() volatile &; using test = ct::remove_member_const_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using f = int() const; using expect = int(); using test = ct::remove_member_const_t<f>; static_assert(std::is_same<test, expect>::value, ""); } }
#include <boost/callable_traits/remove_member_cv.hpp>
template<typename T> using remove_member_cv_t = //see below template<typename T> struct remove_member_cv : detail::remove_member_cv_impl<T> {};
T must be a function
type or a member function pointer type
T is a pointer, it
may not be cv/ref qualified
const and/or
volatile qualifiers from
T, if present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/remove_member_cv.hpp> namespace ct = boost::callable_traits; struct foo {}; int main() { { using pmf = int(foo::*)() const volatile; using expect = int(foo::*)(); using test = ct::remove_member_cv_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = int(foo::*)() const &&; using expect = int(foo::*)() &&; using test = ct::remove_member_cv_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = int(foo::*)() const volatile &; using expect = int(foo::*)() &; using test = ct::remove_member_cv_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using f = int() const volatile; using expect = int(); using test = ct::remove_member_cv_t<f>; static_assert(std::is_same<test, expect>::value, ""); } }
#include <boost/callable_traits/remove_member_reference.hpp>
template<typename T> using remove_member_reference_t = //see below template<typename T> struct remove_member_reference : detail::remove_member_reference_impl<T> {};
T must be a function
type or a member function pointer type
T is a pointer, it
may not be cv/ref qualified
& or
&& qualifiers from
T, if present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/remove_member_reference.hpp> namespace ct = boost::callable_traits; struct foo {}; int main() { { using pmf = int(foo::*)() &; using expect = int(foo::*)(); using test = ct::remove_member_reference_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = int(foo::*)() const &&; using expect = int(foo::*)() const; using test = ct::remove_member_reference_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = int(foo::*)() const volatile &; using expect = int(foo::*)() const volatile; using test = ct::remove_member_reference_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using f = int() &&; using expect = int(); using test = ct::remove_member_reference_t<f>; static_assert(std::is_same<test, expect>::value, ""); } }
#include <boost/callable_traits/remove_member_volatile.hpp>
template<typename T> using remove_member_volatile_t = //see below template<typename T> struct remove_member_volatile : detail::remove_member_volatile_impl<T> {};
T must be a function
type or a member function pointer type
T is a pointer, it
may not be cv/ref qualified
volatile
qualifier from T, if
present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/remove_member_volatile.hpp> namespace ct = boost::callable_traits; struct foo {}; int main() { { using pmf = int(foo::*)() const volatile; using expect = int(foo::*)() const; using test = ct::remove_member_volatile_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = int(foo::*)() volatile &&; using expect = int(foo::*)() &&; using test = ct::remove_member_volatile_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using pmf = int(foo::*)() volatile &; using expect = int(foo::*)() &; using test = ct::remove_member_volatile_t<pmf>; static_assert(std::is_same<test, expect>::value, ""); } { using f = int() const volatile; using expect = int() const; using test = ct::remove_member_volatile_t<f>; static_assert(std::is_same<test, expect>::value, ""); } }
#include <boost/callable_traits/remove_noexcept.hpp>
template<typename T> using remove_noexcept_t = //see below template<typename T> struct remove_noexcept : detail::remove_noexcept_impl<T> {};
T must be one of the
following:
T is a pointer, it
may not be cv/ref qualified
noexcept specifier
from T, if present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/remove_noexcept.hpp> using boost::callable_traits::remove_noexcept_t; static_assert(std::is_same< remove_noexcept_t<int() noexcept>, int() >{}, ""); int main() {}
#include <boost/callable_traits/remove_transaction_safe.hpp>
template<typename T> using remove_transaction_safe_t = //see below template<typename T> struct remove_transaction_safe : detail::remove_transaction_safe_impl<T> {};
T must be one of the
following:
T is a pointer, it
may not be cv/ref qualified
transaction_safe
specifier from T, if
present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/remove_transaction_safe.hpp> namespace ct = boost::callable_traits; using ts = int() transaction_safe; using not_ts = int(); using ts_removed = ct::remove_transaction_safe_t<ts>; static_assert(std::is_same<not_ts, ts_removed>{}, ""); int main() {}
#include <boost/callable_traits/remove_varargs.hpp>
template<typename T> using remove_varargs_t = //see below template<typename T> struct remove_varargs : detail::remove_varargs_impl<T> {};
T must be one of the
following:
T is a pointer, it
may not be cv/ref qualified
...)
from the signature of T,
if present.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(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/return_type.hpp>
template<typename T> using return_type_t = //see below template<typename T> struct return_type : detail::return_type_impl<T> {};
T must be one of the
following:
operator()
T.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits.hpp> namespace ct = boost::callable_traits; using expect = int; struct foo; template<typename T> void test() { using result = ct::return_type_t<T>; static_assert(std::is_same<expect, result>{}, ""); } int main() { test<int()>(); test<int(*)()>(); test<int(&)()>(); test<int() const>(); test<int(foo::*)() const>(); auto x = []() -> int { return 0; }; test<decltype(x)>(); }