This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Use variadic templates for tr1::is_function


On Apr 10, 2007, at 1:34 PM, Paolo Carlini wrote:

Hi again, Doug,

for the first time I'm looking into some details of result_of... and I have some basic curiosities. For example, is not at all clear to me why it doesn't work at all with plain functions (vs function pointers, etc.). Can you do a bit of popularization and explain why this kind of code path cannot be followed, in principle:

#include <type_traits>
#include <cassert>

template<typename>
 struct result_of;

template<typename _Res, typename... _ArgTypes>
 struct result_of<_Res(_ArgTypes...)>
 { typedef _Res type; };

int main()
{
 using std::is_same;
 assert( (is_same<result_of<int (double)>::type, int>::value) );
}

???

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.

Now, you could do something like:

result_of<int(double)(double)>::type

That would be int.

	Cheers,
	Doug


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]