[Bug libstdc++/39676] std::result_of doesn't work

jwakely dot gcc at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Apr 7 14:51:00 GMT 2009



------- Comment #9 from jwakely dot gcc at gmail dot com  2009-04-07 14:51 -------
This is not a bug in C++0x either.  The spec is:

Given an rvalue fn of type Fn and values t1, t2, ..., tN of types T1, T2, ...,
TN in ArgTypes, respectively,
the type member is the result type of the expression fn(t1, t2, ...,tN).

So the original testcase has Fn=int and tries to find the result of calling int
as a function, which is invalid.

The original testcase should be:

  typedef std::result_of<decltype(fn) (long, float)>::type type;

which tells you the result of invoking something of type decltype(fn) with
arguments of type long and float.

Or, to see what happens if you pass it other types:

  typedef std::result_of<decltype(fn) (int, double)>::type type;

This tells you the result of calling e.g. f(0, 0.0), which will result in the
arguments being implicitly converted, and as it's a simple function not a
function object or other callable type with multiple overloads, the result is
always 'int'

I believe this is not a bug.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39676



More information about the Gcc-bugs mailing list