Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2008-05-17 07:52:27

Mark Beinker schrieb:
> Hi,
> it seems that in from boost version 1.34.1 to 1.35.0 the definition of vector_scalar_unary_functor in functional.hpp has changed from
> template<class T>
> struct vector_scalar_unary_functor {
> typedef std::size_t size_type;
> typedef std::ptrdiff_t difference_type;
> typedef T value_type;
> typedef T result_type;
> };
> to
> template<class V>
> struct vector_scalar_unary_functor {
> typedef typename V::value_type value_type;
> typedef typename V::value_type result_type;
> };
> with the effect that the template parameter could no longer be of integral type.

The template parameter must be a 'vector expression' type because the
functor maps a vector expression to a scalar.

> Was this intentionally and why was this change required?
Actually, I do not remember who changed this for what reason.
Unfortunately, the SVN history is too short to find out who applied the
> This breaks code like the example 2 on page
> for implementing custom function on vectors returning scalars.
> Is there any other recommended way to implement scalar function on vectors?
only the type mappings have to be updated:

replace T by V and use V::value_type, V::size_type and
V::difference_type in the type definitions. If you do not want the to
replace the T you can also directly map T to value_type and result_type.
Then the size_type must be taken from the vector type E.