std::result_of
From cppreference.com
Defined in header <type_traits>
|
||
template< class > class result_of; //not defined |
(1) | (since C++11) |
template< class F, class... ArgTypes > class result_of<F(ArgTypes...)>; |
(2) | (since C++11) |
Deduces the return type of a function call expression at compile type.
Contents |
[edit] Member types
Member type | Definition |
type
|
the return type of the function F if called with the arguments ArgTypes...
|
[edit] Possible implementation
template<class> class result_of; template<class F, class... ArgTypes> struct result_of<F(ArgTypes...)> { typedef decltype( std::declval<F>()(std::declval<ArgTypes>()...) ) type; }; |
[edit] Example
struct S { double operator()(char, int&); }; int main() { std::result_of<S(char, int&)>::type f = 3.14; // f has type double }
[edit] See also
(C++11) |
obtains the type of expression in unevaluated context (function template) |