Praxeolitic
Praxeolitic

Reputation: 24039

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

The return type of boost::bind and now std::bind is unspecified.

unspecified bind

What is the return type of boost::bind?

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?

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.

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?

Upvotes: 1

Views: 1005

Answers (2)

Nevin
Nevin

Reputation: 4853

It isn't boost::function or std::function because those both perform type erasure, which may need a memory allocation (bind does not) and typically cannot have the function call inlined.

Upvotes: 0

Ben Voigt
Ben Voigt

Reputation: 283614

Well, for starters there isn't just one return type. It varies greatly depending on the types of the arguments passed in.

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.

Upvotes: 5

Related Questions