Opened 8 years ago

Last modified 6 years ago

#4489 new Feature Requests

References to function object types

Reported by: Christopher Schmidt Owned by: Daniel Walker
Milestone: To Be Determined Component: result_of
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description (last modified by viboes)

The current implementation of boost::result_of doesn't permit Fn in boost::result_of<Fn(Args...)> to be a reference to a class type. I would like to see that changed. Allowing reference-qualified function object types would be in useful with c++11's explicit reference qualification of member functions (n3090 / 13.3.1/4), and this change would bring boost::result_of more in line with c++11's std::result_of, which does allow "reference[s] to function object type[s]" (n3090 / 20.7.6.6)

Change History (7)

comment:1 Changed 8 years ago by Christopher Schmidt

Owner: changed from No-Maintainer to Douglas Gregor

comment:2 Changed 8 years ago by Christopher Schmidt

"The current implementation of boost::result_of permits Fn in boost::result_of<Fn(Args...)>"...

oh, there is a mistake in there. Of course I meant that the current implementation of boost::result_of does not permit Fn in boost::result_of<Fn(Args...)>"...

comment:3 Changed 6 years ago by viboes

Description: modified (diff)

comment:4 Changed 6 years ago by Michel Morin

Owner: changed from Douglas Gregor to Daniel Walker

comment:5 Changed 6 years ago by Michel Morin

Boost's decltype-based result_of already accepts references to function objects. Users can explicitly enable decltype-based result_of by defining BOOST_RESULT_OF_USE_DECLTYPE. Or, in the trunk code, it is automatically enabled when a compiler supports N3276 decltype (e.g. clang-3.1).

For example, on clang-3.1 with the following functor:

struct F
{
    short operator()(int) &  { return 0; }
    float operator()(int) && { return 0; }
};
  • boost::result_of<F& (int)>::type evaluates to short.
  • boost::result_of<F&&(int)>::type evaluates to float.

Is this enough for you? Or, do you want this feature in tr1-style result_of?

comment:6 Changed 6 years ago by anonymous

Milestone: Boost 1.44.0To Be Determined

We could update the old TR1 protocol to handle references to function objects, but that would take some refactoring. It could be done at the same time as refactoring for #6731... But updating TR1 result_of is lower priority.

  • Daniel Walker
Last edited 6 years ago by Daniel Walker (previous) (diff)

comment:7 Changed 6 years ago by Michel Morin

Component: utilityresult_of
Note: See TracTickets for help on using tickets.