Title
valid uses of empty valarrays
Status
cd1
Section
[valarray.cons]
Submitter
Martin Sebor

Created on 2007-01-20.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Reword the Effects clause and Footnote 280 as follows ([valarray.cons]):

valarray();

Effects: Constructs an object of class valarray<T>,279) which has zero length until it is passed into a library function as a modifiable lvalue or through a non-constant this pointer.280)

Postcondition: size() == 0.

Footnote 280: This default constructor is essential, since arrays of valarray are likely to prove useful. There shall also be a way to change the size of an array after initialization; this is supplied by the semantics may be useful. The length of an empty array can be increased after initialization by means of the resize() member function.

Date: 2007-01-20.00:00:00

The Effects clause for the default valarray ctor suggests that it is possible to increase the size of an empty valarray object by calling other non-const member functions of the class besides resize(). However, such an interpretation would be contradicted by the requirement on the copy assignment operator (and apparently also that on the computed assignments) that the assigned arrays be the same size. See the reflector discussion starting with c++std-lib-17871.

In addition, Footnote 280 uses some questionable normative language.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3238
2007-01-20 00:00:00admincreate