|
Boost Users : |
From: Fedor Pikus (fpikus_at_[hidden])
Date: 2004-12-13 01:10:55
I was trying to come up with a solution for the following problem:
say, I want to declare this class
template <typename T1, typename T2> 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 <typename T1, typename T2> 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_at_[hidden]) http://www.pikus.net http://wild-light.com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net