Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/156.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ std::使用显式返回类型绑定_C++_C++11 - Fatal编程技术网

C++ std::使用显式返回类型绑定

C++ std::使用显式返回类型绑定,c++,c++11,C++,C++11,的一个版本允许调用方提供显式返回类型: template< class R, class F, class... Args > /*unspecified*/ bind( F&& f, Args&&... args ); template /*未指定的*/bind(F&&F,Args&&…Args); 当一个人可能使用(或被迫使用)这个版本的std::bind时,这是一个很好的例子吗?回到TR1,在C++11和decltype()存在之前,在许多情

的一个版本允许调用方提供显式返回类型:

template< class R, class F, class... Args >
/*unspecified*/ bind( F&& f, Args&&... args );
template
/*未指定的*/bind(F&&F,Args&&…Args);

当一个人可能使用(或被迫使用)这个版本的
std::bind
时,这是一个很好的例子吗?

回到TR1,在C++11和
decltype()
存在之前,在许多情况下,你无法推断返回类型,必须显式地指定它。@t.C。那么它是遗留代码吗?我认为,大部分情况下。在某些情况下,您可能真的想要强制转换(例如,对于负数,从
int
->
无符号int
->
无符号long
转换通常不同于从
int
直接转换为
无符号long
,或绕过“仅一个用户定义的转换”隐式转换序列的规则),但这是非常罕见的。
std::bind
本身大部分是遗留的。对我来说,递归绑定表达式的奇怪“魔力”意味着我无论如何不能将其用作纯绑定器。使用lambda表达式,忘掉
std::bind
。。。