Класс result_ofresult_of Class
Определяет возвращаемый тип вызываемого типа, который принимает заданные типы аргументов.Determines the return type of the callable type that takes the specified argument types. Добавлено в C++ 14, не рекомендуется в C++ 17.Added in C++14, deprecated in C++17.
СинтаксисSyntax
template<class>
struct result_of; // Causes a static assert
template <class Fn, class... ArgTypes>
struct result_of<Fn(ArgTypes...)>;
// Helper type
template<class T>
using result_of_t = typename result_of<T>::type;
ПараметрыParameters
FNFn
Вызываемый тип для запроса.The callable type to query.
аргтипесArgTypes
Типы списка аргументов к вызываемому типу для запроса.The types of the argument list to the callable type to query.
КомментарииRemarks
Используйте этот шаблон для определения во время компиляции типа результата Fn
( ArgTypes
), где fn — это вызываемый тип, ссылка на функцию или ссылка на вызываемый тип, вызываемая с помощью списка аргументов типов в аргтипес.Use this template to determine at compile time the result type of Fn
(ArgTypes
), where Fn is a callable type, reference to function, or reference to callable type, invoked using an argument list of the types in ArgTypes. type
Член шаблона класса называет тип результата, decltype(std::invoke(declval<Fn>(), declval<ArgTypes>()...))
Если неоцененное выражение std::invoke(declval<Fn>(), declval<ArgTypes>()...)
имеет правильный формат.The type
member of the class template names the result type of decltype(std::invoke(declval<Fn>(), declval<ArgTypes>()...))
if the unevaluated expression std::invoke(declval<Fn>(), declval<ArgTypes>()...)
is well-formed. В противном случае шаблон класса не имеет члена type
.Otherwise, the class template has no member type
. Тип fn и все типы в пакете параметров аргтипес должны быть полными типами, void
или массивами с неизвестной границей.The type Fn and all types in the parameter pack ArgTypes must be complete types, void
, or arrays of unknown bound. Не рекомендуется в пользу invoke_result в c++ 17.Deprecated in favor of invoke_result in C++17.
ТребованияRequirements
Заголовок:<type_traits>Header: <type_traits>
Пространство имен: stdNamespace: std
См. также разделSee also
<type_traits><type_traits>
Класс invoke_resultinvoke_result class