I was trying to come up with a solution for the following problem:
say, I want to declare this class
template class A
{
public:
A( T1 x, T2 y ) : xy( x + y ) {}
private:
The_Right_Type xy;
};
Or I want to declare a function template:
template The_Right_Type f( T1 x, T2 y ) {
return x + y; }
The problem is, of course, what is The_Right_Type?
I could not get a solution better than something which would require
me to "register" all types in some way (then I could get types of all
expressions involving registered types). Then Scott Meyers suggested I
look at boost::result_of.
It looks very cool except I can't figure out how to use it :( I
searched the Boost mailing lists, found some incomplete examples and
some broken tinyurl links, but nothing which would show me how to use
it. Looking at the proposal, I could see how it is used inside a
template where I already have types, but not how to get a type out of
an expression in the first place.
Now the question: can result_of solve the problem above, and would
someone be kind enough to show me an example of how to use it?
Thanks in advance,
Fedor
--
Fedor G Pikus (fpikus@gmail.com)
http://www.pikus.net
http://wild-light.com