Title
Valarray constructor is strange
Status
nad
Section
[template.valarray]
Submitter
AFNOR

Created on 1998-10-07.00:00:00 last changed 163 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

The LWG believes that while the order of arguments is unfortunate, it does not constitute a defect in the standard. The LWG believes that the proposed solution will not work for valarray<size_t> and perhaps other cases.

Date: 2010-10-21.18:28:33

Proposed resolution:

Inverting the arguments could silently break programs. Introduce the two signatures (const T&, size_t) and (size_t, const T&), but make the one we do not want private so errors result in a diagnosed access violation. This technique can also be applied to STL containers.

Date: 1998-10-07.00:00:00

The order of the arguments is (elem, size) instead of the normal (size, elem) in the rest of the library. Since elem often has an integral or floating point type, both types are convertible to each other and reversing them leads to a well formed program.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg576
2010-10-21 18:28:33adminsetmessages: + msg575
1998-10-07 00:00:00admincreate