Boost logo

Boost :

From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-05-31 16:08:56


Hubert HOLIN wrote:
> As far as I understand it, the unspecialized template class
> complex is part of the standard, but it is its instanciation with a
> type other than float, double and long double that has undefined
> behaviour.

No, it has unspecified behaviour. Section 1.3.12 of the standard says
what "undefined" means and section 1.3.13 defines "unspecified".
26.2p2 says the effect of instantiating std::complex for anything
else than "float", "double", and "long double" is unspecified.
Therefore, even defining a variable of type, say, std::complex<int>,
can do anything ranging from giving a diagnostic, to randomly
corrupting the memory of the running process, to formatting your hard
drive.

> I interpret this as: if T has the
> algebraic properties of, say, float, then the algebraic properties of
> complex<T> will be what are expected.

I disagree.

> I believe it would be worthwile, for the next iteration of
> the standard, to be more explicit on that point, perhaps with clauses
> of the style: this behaves "as if" it hab been coded thus and thus, but
> with the possiblities of exceptions being generated.

I don't think it's a defect in the standard, because, in this respect, it's
sufficiently clear and unambiguous as written. If you wish to propose an
extension for the next round of standardization or the upcoming library
Technical Report, consider writing a detailed proposal, suitable to replace
(specified parts of) section 26.2 of the standard. I'd be happy to
forward it to the TR editor.

Also, you could consider joining the ISO committee. If you're from France,
contact AFNOR for the details.

Jens Maurer


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