问题描述
我看到 std :: result_of
在C ++ 17中已被弃用。
I saw std::result_of
is being deprecated in C++17.
- 在C ++ 17中弃用
std :: result_of
的原因是什么? ? - 我也想知道
std :: result_of
和std :: invoke_result
。
- What is the reason for
std::result_of
deprecated in C++17? - Also I would like to know the difference between
std::result_of
andstd::invoke_result
.
推荐答案
TC已经提供了明显的联系,但也许最可怕的原因需要重复: result_of
涉及形成类型 F(Arg1,Arg2,...)
不是用于返回 F
类型的函数,而是用于类型 <$的函数c $ c> F 接受这些类型。 (毕竟,返回类型是 result_of
的结果,而不是输入!)
T.C. already provided the obvious link, but perhaps the most horrific reason bears repeating: result_of
involved forming the type F(Arg1, Arg2, ...)
not for a function of those types returning F
but for a function of type F
accepting those types. (After all, the return type is the result of, well, result_of
, not the input!)
从与形成函数类型相关的调整来看,两者之间唯一的区别就是语法。
Aside from the adjustments associated with forming the function type, the only difference between the two is syntactic.
这篇关于在C ++ 17中不推荐`std :: result_of`的原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!