Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2006-11-15 04:36:07


On Wednesday 15 November 2006 04:25, Manoj Rajagopalan wrote:
> Hi
>
> when we have vector_expression<E>, does E::value_type always evaluate
> to a float or double or long double? Or could it evaluate to something
> more complex like vector_reference<?> or vector_container<?>.
>
> I am writing functions that accept a vector_expression<E> as an
> input. I'd like to know the data type of each element in that vector and
> that is how this question has come up.

These functions look like this:

template<class E>
void foo(const vector_expression<E> &e);

vector<double> d;
vector<void*> p;

if you call foo(d) then E becomes vector<double> because vector_expression<
vector<double> > is the base class of vector<double> (see CRTP). Thus
E::value_type is exactly the same as vector<double>::value_type which indeed
is 'double'.

If you call foo(p) then E::value_type is 'void*'.

mfg
Gunter