Boost logo

Boost :

From: rwgk (rwgk_at_[hidden])
Date: 2002-03-06 14:31:44

In light of the upcoming Curacao meeting David Abrahams and
myself are discussion a proposal for the revision of
std::complex. Attached is one facet from our discussion. We
would like to hear comments if there are different

David Abrahams wrote:
> I need you to explain why we need a complex<> with a
> predictable POD-like layout and a way to avoid
> initializing the members (anything else important about
> complex<>?)

Regarding David's last point:

It seems to me that this is more a question of how
containers work rather than one of the design of


  std::vector<T>(1000000); // elements are default constructed -> T()

B. Stroustrup writes (section 6.2.8 of The C++ Prog. Lang.):

"The value of an explicit use of the constructor for a
built-in type is 0 converted to that type."

Do we want std::complex<T> to behave differently than
built-in types?

Here is a more general solution that will work for any type
that has a trivial destructor:

From files misc.h and shared_plain.h at:

  struct no_initialization_flag {};

  template <typename ElementType>
  class shared_plain {
      // ...
      shared_plain(const size_type& sz, no_initialization_flag)
        : m_is_weak_ref(false),
          m_handle(new handle_type(sz * element_size()))
        m_handle->size = m_handle->capacity;
      // ...

IMO both std::vector and std::valarray should have a
similar additional constructor.
This suggestion requires that type traits are part of the
standard. Is this likely to happen any time soon?


Boost list run by bdawes at, gregod at, cpdaniel at, john at