Boost logo

Ublas :

From: Nico Galoppo (nico_at_[hidden])
Date: 2007-10-06 00:18:27


Hi,

I have the snippet of code below that compiles OK with MSVC 8.0, but
fails with gcc 4.0.1 (OSX). I guess my question is whether my
templated helper function is actually valid, or violating the C++
spec.

template <typename V, typename T>
inline void assign(ublas::vector_expression<V>& bv, const vector3<T>&
{
    for (unsigned int i = 0; i < 3; ++i)
        bv () (i) = v(i);
}

int main()
{
  ublas::vector<float> v(100);
  vec3<float> tuple;

  assign(subrange(v, 3,6), tuple);
}

vec3<T> is a specialized (non-ublas) 3-vector class. gcc gives an
error at the 'assign' line in main():

error: invalid initialization of non-const reference of type
'boost::numeric::ublas::vector_expression<boost::numeric::ublas::vector_range<boost::numeric::ublas::vector<float,
boost::numeric::ublas::unbounded_array<float, std::allocator<float> >
> > >&' from a temporary of type
'boost::numeric::ublas::vector_range<boost::numeric::ublas::vector<float,
boost::numeric::ublas::unbounded_array<float, std::allocator<float> >
> >'

-- 
Nico Galoppo :: http://www.ngaloppo.org