为什么未指定std :: bind的返回类型? [英] Why is the return type of std::bind unspecified?
问题描述
未指定boost::bind
和现在的std::bind
的返回类型.
The return type of boost::bind
and now std::bind
is unspecified.
为什么未指定boost::bind
和现在的std::bind
的返回类型?为什么没有像boost::function
和std::function
这样的东西?
Why is it that the return type of boost::bind
and now std::bind
is unspecified? Why isn't it something like boost::function
and std::function
?
我意识到,意图是通过类型推导来引用返回类型,但这并不能回答为什么std::bind
是特殊的.
I realize that the intent is to refer to the return type via type deduction but that doesn't answer why std::bind
is special.
如果那只是委员会的一时兴致,那么没什么可说的,但是有技术上的原因,即为std::bind
指定返回类型非常麻烦,或者没有指定返回类型将允许更有效的实现?
If that was just the whim of the committee then ok, there's not much else to say, but is there a technical reason that specifying a return type for std::bind
is uniquely burdensome or that not specifying it permits a more efficient implementation?
推荐答案
好吧,对于初学者来说,不仅只有一种返回类型.根据传入的参数类型的不同,其差异很大.
Well, for starters there isn't just one return type. It varies greatly depending on the types of the arguments passed in.
C ++标准为实现者提供了很大的灵活性,使他们可以准确地了解如何区分不同的情况(使用重载和SFINAE)并将其映射到不同的闭包对象类型.
The C++ Standard is leaving a lot of flexibility to implementers exactly how different cases are broken out (using overloading and SFINAE) and mapped onto different closure object types.
这篇关于为什么未指定std :: bind的返回类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!