Boost logo

Boost :

From: Joe Gottman (joegottman_at_[hidden])
Date: 2002-02-27 20:58:18


----- Original Message -----
From: <nbecker_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, February 27, 2002 2:30 PM
Subject: Re: [boost] Re: std::complex design (Was: N-Dimensional array
library submission...)

> Another problem with std::complex is that is has a default
> initializer. Constructing a vector<complex> will cause the default
> initializer to be called potentially a large number of times. This
> can be very wasteful. I believe a complex type for serious numerical
> processing should not have a default constructor.

   Why not? If you write vector<complex<double> > vec(10); you have made
a conscious decision to create a vector that started with 10 complex
numbers. Its not unreasonable for a user to use one of those complex
numbers. If you just wanted to reserve space for 10 complex numbers you
could have just used the default constructor then called reserve().
Besides, the default constructor is inline, so how slow could it be?

Joe Gottman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk