Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Parameter List Features

function_type
args
arg_at
clear_args
remove_args
replace_args
insert_args
pop_back_args
pop_front_args
push_back_args
push_front_args
expand_args
expand_args_left
expand_args_right
add_varargs
remove_varargs
has_varargs
Header
#include <boost/callable_traits/function_type.hpp>
Definition
template<typename T>
using function_type_t = //implementation-defined

template<typename T>
struct function_type {
    using type = function_type_t<T>;
};
Constraints
  • T must be one of the following:
    • function
    • function pointer
    • function reference
    • member function pointer
    • member data pointer
    • user-defined type with a non-overloaded operator()
    • type of a non-generic lambda
Behavior
  • When the constraints are violated, a substitution failure occurs.
  • When 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.
  • When T is a function pointer, the aliased type is equivalent to std::remove_pointer_t<T>.
  • When T is a function reference, the aliased type is equivalent to std::remove_reference_t<T>.
  • When T is a function object, the aliased type is a function type with the same return type and parameter list as T's operator().
  • When 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.
  • When 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.
  • In all cases, the aliased function type will not have member qualifiers, and will not have the transaction_safe specifier.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

function_type_t<T>

void(int)

void(int)

void(int) const

void(int)

void(int) transaction_safe

void(int)

void(*)(int)

void(int)

void(&)(int)

void(int)

void(*)()

void()

int(foo::*)(int)

int(foo&, int)

int(foo::*)(int) const

int(const foo&, int)

void(foo::*)() volatile &&

void(volatile foo&&)

int foo::*

int(const foo&)

const int foo::*

int(const foo&)

int

(substitution failure)

int (*const)()

(substitution failure)

Example Program
#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>();
}
Header
#include <boost/callable_traits/args.hpp>
Definition
template<typename T>
using args_t = //implementation-defined

template<typename T>
struct args {
    using type = args_t<T>;
};
Constraints
  • T must be one of the following:
    • function
    • function pointer
    • function reference
    • member function pointer
    • member data pointer
    • user-defined type with a non-overloaded operator()
    • type of a non-generic lambda
Behavior
  • When the constraints are violated, a substitution failure occurs.
  • When 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.
  • When 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.
  • When 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.
  • When 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.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

args_t<T>

void(float, char, int)

std::tuple<float, char, int>

void(*)(float, char, int)

std::tuple<float, char, int

void(&)(float, char, int)

std::tuple<float, char, int

void(float, char, int) const &&

std::tuple<float, char, int>

void(*)()

std::tuple<>

void(foo::*)(float, char, int)

std::tuple<foo&, float, char, int>

int(foo::*)(int) const

std::tuple<const foo&, int>

void(foo::*)() volatile &&

std::tuple<volatile foo &&>

int foo::*

std::tuple<const foo&>

const int foo::*

std::tuple<const foo&>

int

(substitution failure)

int (*const)()

(substitution failure)

Example Program
#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>();
    }
}
Header
#include <boost/callable_traits/arg_at.hpp>
Definition
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>;
};
Constraints
  • T must be one of the following:
    • function
    • function pointer
    • function reference
    • member function pointer
    • member data pointer
    • user-defined type with non-overloaded operator()
    • type of a non-generic lambda
  • I must be less than std::tuple_size<boost::callable_traits::args_t<T>>::value
Behavior
  • If any constraints are violated, a substitution failure occurs.
  • Otherwise, arg_at_t<Index, T> is equivalent to std::tuple_element_t<Index, boost::callable_traits::args_t<T>>.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Example Program
#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(&lt::operator());
    using object_ref = ct::arg_at_t<0, pmf>;
    static_assert(std::is_same<object_ref, lt const &>::value, "");
}
Header
#include <boost/callable_traits/clear_args.hpp>
Definition
template<typename T>
using clear_args_t = //implementation-defined

template<typename T>
struct clear_args {
    using type = clear_args_t<T>;
};
Constraints
  • T must be one of the following:
    • function
    • function pointer
    • function reference
    • member function pointer
Behavior
  • When the constraints are violated, a substitution failure occurs.
  • The aliased type has an empty parameter list, but is otherwise identical to T.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

clear_args_t<T>

void(float, char, int)

void()

void(*)(float, char, int)

void(*)()

void(&)(float, char, int)

void(&)()

void(float, char, int) const &&

void() const &&

void(*)()

void(*)()

void(foo::*)(float, char, int)

void(foo::*)()

int(foo::*)(int) const

int(foo::*)() const

void(foo::*)() volatile &&

void(foo::*)() volatile &&

int foo::*

(substitution failure)

int

(substitution failure)

int (*const)()

(substitution failure)

Example Program
#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, "");
}
Header
#include <boost/callable_traits/remove_args.hpp>
Definition
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>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
  • 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
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Behavior
  • A substitution failure occurs at if the constraints are violated.
  • The aliased type is identical to 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.
  • Input/Output Examples

    T

    remove_args_t<1, T, 2>

    int(A, B, C, D)

    int(A, D)

    int(*)(A, B, C, D)

    int(*)(A, D)

    int(&)(A, B, C, D)

    int(&)(A, D)

    int(foo::*)(A, B, C, D)

    int(foo::*)(A, B, C, D)

Example Program
#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, "");
}
Header
#include <boost/callable_traits/replace_args.hpp>
Definition
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...>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
  • Index must be less than the number of parameters in the parameter list of T
Behavior
  • A substitution failure occurs if the constraints are violated.
  • The aliased type is identical to T, except that the parameter list types are "overwritten" by Args..., beginning at zero-based Index.
  • * If sizeof...(Args) is greater than then number of function parameters in T minus Index, the aliased type will contain more parameters than T.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

replace_args_t<1, T, float, double>

int(int, char) const

int(int, float, double) const

int(&)(int, char)

int(&)(int, float, double)

int(*)(int, char) transaction_safe

int(*)(int, float, double) transaction_safe

int(foo::*)(int, char)

int(foo::*)(int, float, double)

int(foo::*)(int, char) const

int(foo::*)(int, float, double) const

int

(substitution failure)

int foo::*

(substitution failure)

int (* const)()

(substitution failure)

Example Program
#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, "");
}
Header
#include <boost/callable_traits/insert_args.hpp>
Definition
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...>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
  • Index must be less than or equal to the number of parameters in the parameter list of T
Behavior
  • A substitution failure occurs if the constraints are violated.
  • The aliased type is identical to T, except that Args... are inserted into the parameter list of T, at Index (zero-based).
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

insert_args_t<1, T, foo, bar>

int(int)

int(int, foo, bar)

int(int, char) const &

int(int, foo, bar, char) const &

int(*)(int) transaction_safe

int(*)(int, foo, bar) transaction_safe

int(*)(int, char)

int(*)(int, foo, bar, char)

int(&)(int)

int(&)(int, foo, bar)

int(&)(int, char)

int(&)(int, foo, bar, char)

int(foo::*)(int) const

int(foo::*)(int, foo, bar) const

int(foo::*)(int, char)

int(foo::*)(int, foo, bar, char) const

int()

(substitution failure)

int(foo::*)()

(substitution failure)

int

(substitution failure)

int foo::*

(substitution failure)

int (* const)()

(substitution failure)

Example Program
#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, "");
}
Header
#include <boost/callable_traits/pop_back_args.hpp>
Definition
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>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
Behavior
  • A substitution failure occurs if the constraints are violated.
  • The aliased type is identical to T, except that Count number of parameters are removed from the back of the parameter list.
  • If Count is greater than or equal to the number of parameters in T, then the aliased type will have an empty parameter list.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

pop_back_args_t<T, 2>

int(char, short, int) const &&

int(char) const &&

int(*)(char, short, int)

int(*)(char)

int(&)(char, short, int)

int(&)(char)

int(foo::*)(char, short, int)

int(foo::*)(char)

Example Program
#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() {}
Header
#include <boost/callable_traits/pop_front_args.hpp>
Definition
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>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
Behavior
  • A substitution failure occurs if the constraints are violated.
  • The aliased type is identical to T, except that Count number of parameters are removed from the front of the parameter list.
  • If Count is greater than or equal to the number of parameters in T, then the aliased type will have an empty parameter list.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

pop_front_args_t<T, 2>

int(char, short, int) const &&

int(int) const &&

int(*)(char, short, int)

int(*)(int)

int(&)(char, short, int)

int(&)(int)

int(foo::*)(char, short, int)

int(foo::*)(int)

Example Program
#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() {}
Header
#include <boost/callable_traits/push_back_args.hpp>
Definition
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...>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
Behavior
  • A substitution failure occurs if the constraints are violated.
  • The aliased type is identical to T, except that Args... types have been added to the back of the parameter list.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

push_back_args_t<T, float, double>

int(char) const &&

int(char, float, double) const &&

int(*)(char)

int(*)(char, float, double)

int(&)(char)

int(&)(char, float, double)

int(foo::*)(char)

int(foo::*)(char, float, double)

Example Program
#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, "");
}
Header
#include <boost/callable_traits/push_front_args.hpp>
Definition
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...>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
Behavior
  • A substitution failure occurs if the constraints are violated.
  • The aliased type is identical to T, except that Args... types have been added to the front of the parameter list.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

push_front_args_t<T, float, double>

int(char)

int(float, double, char)

int(*)(char)

int(*)(float, double, char)

int(&)(char)

int(&)(float, double, char)

int(foo::*)(char) volatile

int(foo::*)(float, double, char) volatile

Example Program
#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, "");
}
Header
#include <boost/callable_traits/expand_args.hpp>
Definition
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>;
};
Constraints
  • T must be one of the following:
    • function
    • function pointer
    • function reference
    • member function pointer
    • member data pointer
    • user-defined type with a non-overloaded operator()
    • type of a non-generic lambda
Behavior
  • When the constraints are violated, a substitution failure occurs.
  • When 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.
  • When T is a function object, the aliased type is the Container template instantiated with the types from the parameter list of T's operator().
  • When 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.
  • When T is a member data pointer, the aliased type is the Container template instantiated with a const reference to the parent class of T.
  • If Container cannot be legally instantiated according to the behavior defined above with respect to T, the behavior is undefined.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

expand_args_t<T, std::tuple>

void(float, char, int)

std::tuple<float, char, int>

void(*)(float, char, int)

std::tuple<float, char, int>

void(&)(float, char, int)

std::tuple<float, char, int>

void(float, char, int) const &&

std::tuple<float, char, int>

void(*)()

std::tuple<>

void(*)() transaction_safe

std::tuple<>

void(foo::*)(float, char, int)

std::tuple<foo&, float, char, int>

int(foo::*)(int) const

std::tuple<const foo&, float, char, int>

void(foo::*)() volatile &&

std::tuple<volatile foo &&>

int foo::*

std::tuple<const foo&>

int

(substitution failure)

int (*const)()

(substitution failure)

Example Program
#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, "");
}
Header
#include <boost/callable_traits/expand_args_left.hpp>
Definition
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...>;
};
Constraints
  • T must be one of the following:
    • function
    • function pointer
    • function reference
    • member function pointer
    • member data pointer
    • user-defined type with a non-overloaded operator()
    • type of a non-generic lambda
Behavior
  • When the constraints are violated, a substitution failure occurs.
  • 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....
  • If Container cannot be legally instantiated according to the behavior defined above with respect to T and RightArgs..., the behavior is undefined.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

expand_args_left_t<T, std::tuple, short, void*>

void(float, char, int)

std::tuple<float, char, int, short, void*>

void(*)(float, char, int)

std::tuple<float, char, int, short, void*>

void(&)(float, char, int)

std::tuple<float, char, int, short, void*>

void(float, char, int) const &&

std::tuple<float, char, int, short, void*>

void(*)()

std::tuple<short, void*>

void(*)() transaction_safe

std::tuple<short, void*>

void(foo::*)(float, char, int)

std::tuple<foo&, float, char, int, short, void*>

int(foo::*)(int) const

std::tuple<const foo&, float, char, int, short, void*>

void(foo::*)() volatile &&

std::tuple<volatile foo &&, short, void*>

int foo::*

std::tuple<const foo&, short, void*>

int

(substitution failure)

int (*const)()

(substitution failure)

Example Program
#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, "");
}
Header
#include <boost/callable_traits/expand_args_right.hpp>
Definition
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...>;
};
Constraints
  • T must be one of the following:
    • function
    • function pointer
    • function reference
    • member function pointer
    • member data pointer
    • user-defined type with a non-overloaded operator()
    • type of a non-generic lambda
Behavior
  • When the constraints are violated, a substitution failure occurs.
  • 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...).
  • If Container cannot be legally instantiated according to the behavior defined above with respect to T and LeftArgs..., the behavior is undefined.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

expand_args_right_t<T, std::tuple, short, void*>

void(float, char, int)

std::tuple<short, void*, float, char, int>

void(*)(float, char, int)

std::tuple<short, void*, float, char, int>

void(&)(float, char, int)

std::tuple<short, void*, float, char, int>

void(float, char, int) const &&

std::tuple<short, void*, float, char, int>

void(*)()

std::tuple<short, void*>

void(*)() transaction_safe

std::tuple<short, void*>

void(foo::*)(float, char, int)

std::tuple<short, void*, foo&, float, char, int>

int(foo::*)(int) const

std::tuple<short, void*, const foo&, float, char, int>

void(foo::*)() volatile &&

std::tuple<short, void*, volatile foo &&>

int foo::*

std::tuple<short, void*, const foo&>

int

(substitution failure)

int (*const)()

(substitution failure)

Example Program
#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, "");
}
Header
#include <boost/callable_traits/add_varargs.hpp>
Definition
template<typename T>
using add_varargs_t = //implementation-defined

template<typename T>
struct add_varargs {
    using type = add_varargs_t<T>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
Behavior
  • A substitution failure occurs if the constraints are violated.
  • Adds C-style variadics (...) to the signature of T, if not already present.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

add_varargs_t<T>

int()

int(...)

int(int)

int(int, ...)

int (&)()

int(&)(...)

int (*)()

int(*)(...)

int (*)(...)

int(*)(...)

int(foo::*)()

int(foo::*)(...)

int(foo::*)() &

int(foo::*)(...) &

int(foo::*)() &&

int(foo::*)(...) &&

int(foo::*)() const

int(foo::*)(...) const

int(foo::*)() transaction_safe

int(foo::*)(...) transaction_safe

int

(substitution failure)

int foo::*

(substitution failure)

int (*&)()

(substitution failure)

Example Program
#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, "");
    }
}
Header
#include <boost/callable_traits/remove_varargs.hpp>
Definition
template<typename T>
using remove_varargs_t = //implementation-defined

template<typename T>
struct remove_varargs {
    using type = remove_varargs_t<T>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
Behavior
  • A substitution failure occurs if the constraints are violated.
  • Removes C-style variadics (...) from the signature of T, if present.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

remove_varargs_t<T>

int(...)

int()

int(int, ...)

int(int)

int (&)(...)

int(&)()

int (*)()

int(*)()

int(foo::*)(...)

int(foo::*)()

int(foo::*)(...) &

int(foo::*)() &

int(foo::*)(...) &&

int(foo::*)() &&

int(foo::*)(...) const

int(foo::*)() const

int(foo::*)(...) transaction_safe

int(foo::*)() transaction_safe

int

(substitution failure)

int foo::*

(substitution failure)

int (* const)()

(substitution failure)

Example Program
#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, "");
    }
}
Header
#include <boost/callable_traits/has_varargs.hpp>
Definition
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
Constraints
  • none
Behavior
  • 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().
  • On compilers that support variable templates, has_varargs_v<T> is equivalent to has_varargs<T>::value.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

has_varargs_v<T>

void(...)

true

void(int, ...) const

true

void(*)(...)

true

void(&)(...)

true

void(foo::*)(...) const

true

void(*)()

false

void(*&)()

false

int

false

const int

false

int foo::*

false

Example Program
#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() {}

PrevUpHomeNext