Opened 12 years ago

Last modified 10 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 by Christopher Schmidt, 12 years ago

Owner: changed from No-Maintainer to Douglas Gregor

comment:2 by Christopher Schmidt, 12 years ago

"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 by viboes, 10 years ago

Description: modified (diff)

comment:4 by Michel Morin, 10 years ago

Owner: changed from Douglas Gregor to Daniel Walker

comment:5 by Michel Morin, 10 years ago

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 by anonymous, 10 years ago

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 10 years ago by Daniel Walker (previous) (diff)

comment:7 by Michel Morin, 10 years ago

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