Subject: Re: [boost] [complex] Feedback and Potential Review Manager
From: Christopher Kormanyos (e_float_at_[hidden])
Date: 2012-05-07 16:35:16
>> but rather the default ctor of the template type.
>> complex(const T& re = T(), const T& im = T());
> Do I understand correctly that the default constructor
> does not set real and imag parts to zero?
Well, it's appears to be more subtle than we might want
it to be. ISO/IEC 14882:2011 specifies the T() form for
the generalized complex template. The language
specification goes on, however, to specify
that only float, double and long double are
valid template parameters for complex.
And the subsequent template specializations
for the built-in floating-point numbers have
default values of 0.0F, 0.0, 0.0L.
For example, as in my other post, the specified
constructor for float is:
complex(float re = 0.0F, float im = 0.0F);
I also believe that the value of, say, the default
constructor of float is zero. In particular
// F1 is initialized to zero.
float f1 = float();
So ISO/IEC 14882:2011 ensures that all valid uses
of complex are default initialized to zero. Without
judgement, this is the spec.
What a potential Boost.Complex should do for
user-defined types that may potentially default construct
to non-zero is an open issue.
Best regards, Chris.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk