Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2007-02-02 04:24:26

On Thursday 01 February 2007 19:59, Neal Becker wrote:
> I am (once again) looking into avoiding unnecessary construction of
> vector/matrix. In particular, this is interesting for std::complex, since
> (unfortunately) it's constructor is non-trivial.
> I am looking into the following. In storage.hpp, use
> boost::has_trivial_constructor
> to dispatch.

Can this be done via a special Allocator? I think the least intrusive method
should be to have an allocator that initilizes the new storage and to have
one that does not do this. (The change would be to call alloc.contruct(..)
instead of explicite use value_type(). Right?)

> vector (size, init_value)
> matrix (size1, size2, init_value)

The same can be done by using the copy constructor:

vector<double> v = scalar_vector<double>(size, value);

IMO the default behaviour of 'no construction' should be enough.