This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

### 620. valid uses of empty valarrays

Section: 26.7.2.2 [valarray.cons] Status: CD1 Submitter: Martin Sebor Opened: 2007-01-20 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [valarray.cons].

View all issues with CD1 status.

Discussion:

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.

Proposed resolution:

Reword the Effects clause and Footnote 280 as follows (26.7.2.2 [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.