为什么未指定 std::bind 的 return 类型?

Why is the return type of std::bind unspecified?

未指定 boost::bind 和现在的 std::bind 的 return 类型。

unspecified bind

What is the return type of boost::bind?

为什么 boost::bind 和现在的 std::bind 的 return 类型未指定?为什么不是 boost::functionstd::function 之类的东西?

我意识到其目的是通过类型推导来引用 return 类型,但这并没有回答为什么 std::bind 是特殊的。

如果那只是委员会的心血来潮,那么好吧,没什么好说的,但是是否有技术原因导致 std::bind 指定 return 类型是独一无二的繁琐或者不指定它允许更有效的实施?

嗯,对于初学者来说,不只有一种 return 类型。它根据传入的参数类型而有很大差异。

C++ 标准为实现者留下了很大的灵活性,具体来说就是如何分解不同的情况(使用重载和 SFINAE)并映射到不同的闭包对象类型。

它不是 boost::function 或 std::function,因为它们都执行类型擦除,这可能需要内存分配(bind 不需要)并且通常不能内联函数调用。