|
Ublas : |
From: Michael Stevens (mail_at_[hidden])
Date: 2005-02-05 12:48:04
On Friday 04 February 2005 03:13, Robbie Vogt wrote:
> On a similar note, it would appear that the following is not possible
> with v1.32:
>
> vector<double> a, b, c;
>
> c = project(a+b, range(i,j));
>
> This fails because the expression created to represent a+b doesn't have
> a vector_temporary_type, which the proxy (vector_slice in this case,
> which also seems strange) seems to require.
The appearance vector_slice does seem strange. I'm not sure if this is a side
effect of the main error however. To simplify the situation efining the
following and using it instead still fails.
template<class V>
const ublas::vector_range<const V> myproject (const V &data, const
typename ublas::vector_range<V>::range_type &r) {
// ISSUE was: return vector_range<V> (const_cast<V &> (data), r);
return ublas::vector_range<const V> (data, r);
}
In fact simply instantiating the vector_range template with the following
fails:
myproject(a+b, ublas::range(0,0))
The problem is occurring because the type
vector_range<V>::vector_temporary_type is not defined in such an instantiation
(where V is a vector_binary). Why this is an error I am not sure as the type
is never used and class member functions which depend on it are ever
instantiated. This seems to go against the usual "is not an error" rules
related to template definitions.
Anyone care to enlighten me why this is an error in this case.
The good news is that the current CVS head does not have this problem. Here
Karl's vector_temporary_traits mechanism is used instead.
Michael