Boost logo

Ublas :

From: Peter Schmitteckert (peter_at_[hidden])
Date: 2005-08-16 13:57:22


Salut,

On Tue, 16 Aug 2005, Michael Stevens wrote:

> > IMHO this does not correctly use the allocator. Looking at std::vector the
> > constructor should read:
> >
> > explicit BOOST_UBLAS_INLINE
> > unbounded_array (size_type size, const ALLOC &a = ALLOC()):
> > alloc_(a), size_ (size) {
> > if (size_) {
> > data_ = alloc_.allocate (size_);
> > }
> > else
> > data_ = 0;
> > }
>
> I think this is wrong. Before an element in std::vector is used it is always
> initialised by placed copy constructor. This is why this std::vector
> constructor with a size takes a default argument of type T with the value
> T().

but maybe

#ifndef NDEBUG
  else
    data_ = NULL;
#endif

might be a good idea.

Best wishes,
Peter