Boost logo

Boost :

From: Maxim Litvinov (boost_at_[hidden])
Date: 2002-12-30 08:11:25

Hi all.
Is there any way to determine type of expression statically?
Not just string representation or ID (like typeid() does), but type itself.
So I could create objects of the same type.
It could be useful, when result of expression is not clear to programmer.
For example, to save result of expression you COULD use something like:

template <class T>
struct type
    typedef T type;

template <class T> type<T> typeof(T&)
    { return type<T>(); }

void test()
    A a;
    B b;
    typeof(a+b).type result; //does not compile, only type<C>::type works
Of course it doesn't work since C++ compilers doesn't allow to select types
with operator. , only with operator::
So? Is there any other way?


Boost list run by bdawes at, gregod at, cpdaniel at, john at