Boost logo

Ublas :

From: Michael Stevens (m-stevens_at_[hidden])
Date: 2005-01-31 10:14:19


Hi All,

I have been re-reading all the comments. I think there is general agreement
that requiring value_type(0) construction is not what we want in the future.
Karl pointed out what we thought should be the way to go in the developer
meeting.

For now I think it would be sufficient to make it clear in uBLAS documentation
that value_type() needs to behave as the 'zero' value in the linear algebra
of value_type.

In the current CVS HEAD value_type(0) provides a useful placeholder for future
development. To further this but I have replaced all value_type (0) in the
CVS HEAD with
        value_type/*zero*/()
This drops the value_type (0) construction requirement for all containers an
functions.

With regards to Boost_1_32_0 it had several locations (particularly in resize)
that incorrectly require value_type(0) construction. I have committed fixes
to the RC_1_32_0 branch with fixes for all this as well.

On Tuesday 25 January 2005 14:04, Ian McCulloch wrote:

> I thought the reason why value_type() not preferred was that someone had
> some examples of user-types for which the default ctor didn't initialize to
> logical zero? I think that is reasonable. But value_type(0) will cause
> problems I think. Consider
>
> struct SymbolicValue
> {
> SymbolicValue(std::string const& Value) : Value_(Value) {}
> SymbolicValue(char const* Value) : Value_(Value) {}
>
> // operator=, +=, +, -, ...
>
> std::string Value_;
> };

>
> int main()
> {
> ublas::matrix<SymbolicValue> M(10,10); // oops!
> }

I think you can blame SymbolicValue for not using 'explict' in the pointer
constructor. That said the less of this kind of thing the better and
value_type(0) is going to run into these problems.

Cheers,
        Michael