![]() |
Home | Libraries | People | FAQ | More |
#include <boost/callable_traits/return_type.hpp>
template<typename T> using return_type_t = //implementation-defined template<typename T> struct return_type { using type = return_type_t<T>; };
T must be one of the
following:
operator()
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 <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)>(); }
#include <boost/callable_traits/apply_return.hpp>
template<typename T, typename R> using apply_return_t = //implementation-defined template<typename T, typename R> struct apply_return { using type = apply_return_t<T, R>; };
T must one of the following:
std::tuple template instantiation
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::*.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
[apply_return]
#include <boost/callable_traits/has_void_return.hpp>
template<typename T> struct has_void_return; //implementation-defined #ifdef CALLABLE_TRAITS_DISABLE_VARIABLE_TEMPLATES template<typename T> struct has_void_return_v { static_assert(sizeof(T) < 1, "Variable templates not supported on this compiler."); }; #else template<typename T> constexpr bool has_void_return_v = //implementation-defined #endif
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.
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_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() {}