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. |
| Заголовочный файл <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. (шаблон функции) |