std::result_of
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <type_traits>
|
||
| template< class > class result_of; //not defined |
(1) | (C++11 起) |
| template< class F, class... ArgTypes > class result_of<F(ArgTypes...)>; |
(2) | (C++11 起) |
推导出一个函数调用表达式的返回值类型在编译的时候.
Original:
Deduces the return type of a function call expression at compile time.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目录 |
[编辑] 会员类型
| 会员类型
Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
type
|
返回类型的函数
F如果调用参数ArgTypes...Original: the return type of the function F if called with the arguments ArgTypes...The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[编辑] 可能的实现
template<class> struct result_of; template<class F, class... ArgTypes> struct result_of<F(ArgTypes...)> { typedef decltype( std::declval<F>()(std::declval<ArgTypes>()...) ) type; }; |
[编辑] 为例
struct S { double operator()(char, int&); }; int main() { std::result_of<S(char, int&)>::type f = 3.14; // f has type double }
[编辑] 另请参阅
| (C++11) |
在未经评估的情况下获得了表达式的类型 Original: obtains the type of expression in unevaluated context The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数模板) |