|
Ublas : |
From: Darin DeForest (darin_at_[hidden])
Date: 2005-08-09 20:44:39
I'm trying to use scalar_vector for a r-value in a vector assignment. Such as:
vector<int> a;
a = scalar_vector( 3, 4 ); // 3 elements of the value 4
This is generating a compiler error with the 1.33 rc2 boost code.
error C2039: 'size' : is not a member of 'boost::numeric::ublas::vector_container<C>'
For this method in class vector:
template<class C> // Container assignment without temporary
BOOST_UBLAS_INLINE
vector &operator = (const vector_container<C> &v) {
resize (v.size (), false); // **<=== size on the vector container needed.
assign (v);
return *this;
}
When I look at vector_container, and it's parent class vector_expression, I don't see a size method defined.
The work around seems to be
a.assign( scalar_vector( 3, 4) );
Which then treats the scalar_vector as an expression and uses method in class vector
template<class AE>
BOOST_UBLAS_INLINE
vector &assign (const vector_expression<AE> &ae) {
vector_assign<scalar_assign> (*this, ae);
return *this;
}