[Patch] Use variadic templates for tr1::is_function

Doug Gregor dgregor@cs.indiana.edu
Tue Apr 10 18:08:00 GMT 2007


On Apr 10, 2007, at 2:02 PM, Paolo Carlini wrote:

> Doug Gregor wrote:
>
>> That's not a valid use of result_of.
>>
>> result_of<F(A1, A2, ..., AN)>::type is the return type when  
>> calling a  function object of type F with arguments a1, a2, ...,  
>> aN of types A1,  A2, ..., AN, respectively. In your example use, F  
>> is "int", which is  not a valid function object.
>
> Humm, ok, thanks, I'm still trying to digest the whole idea...


>> Now, you could do something like:
>>
>>     result_of<int(double)(double)>::type
>>
>> That would be int.
>
> But, unless I'm doing some stupid mistake, it doesn't compile...

I'm terrible at declarator syntax :)

Anyway, this works fine:

	typedef int (*F)(double); // F is the type of a function object. It  
happens to be a function pointer

	std::result_of<F(double)>::type // resolves to "int"

	Cheers,
	Doug



More information about the Libstdc++ mailing list