Topic: N2369 library problem: Incomplete valarray::operator[] specification in [valarray.access]


Author: =?iso-8859-1?q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Mon, 27 Aug 2007 07:26:53 CST
Raw View
Since the return type of valarray's operator[] const overload has been
changed to
const T& as described in

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#389

several paragraphs of the section [valarray.access] are now
incompletely
specified, because many requirements and guarantees should now also
apply to the const overload. Most notably, the address and reference
guarantees should be extended to the const overload case.

Proposed resolution:

(a) Change [valarray.access]/1 from

"When applied to a constant array, the subscript operator returns a
reference to the corresponding element of the array. When applied to
a non-constant array, the subscript operator returns a reference to
the
corresponding element of the array."

to

"The subscript operator returns a reference to the corresponding
element of the array."

N.B.: The 2nd sentence replicates the first one, so remove the 2nd
sentence
and remove the leading subordinate clause "When applied to a constant
array,"
of the first one.

(b) Change [valarray.access]/3 from

"The expression &a[i+j] == &a[i] + j evaluates as true for all size_t
i and
size_t j such that i+j is less than the length of the non-constant
array a."

to

"The expression &a[i+j] == &a[i] + j evaluates as true for all size_t
i and
size_t j such that i+j is less than the length of the array a."

N.B: Remove "non-constant" from the original sentence.

(c) Change [valarray.access]/4 from

"Likewise, the expression &a[i] != &b[j] evaluates as true for any two
non-constant
arrays a and b and for any size_t i and size_t j such that i is less
than the length
of a and j is less than the length of b. This property indicates an
absence of aliasing
and may be used to advantage by optimizing compilers.281)"

to

"Likewise, the expression &a[i] != &b[j] evaluates as true for any two
arrays a and b
and for any size_t i and size_t j such that i is less than the length
of a and j is less
than the length of b. This property indicates an absence of aliasing
and may be used
to advantage by optimizing compilers.281)"

N.B: Remove "non-constant" from the original sentence.

(d) Change [valarray.access]/5 from

"The reference returned by the subscript operator for a non-constant
array is
guaranteed to be valid until the member function resize(size_t, T)
(26.5.2.7) is
called for that array or until the lifetime of that array ends,
whichever happens first."

to

"The reference returned by the subscript operator for an array is
guaranteed to be valid until the member function resize(size_t, T)
(26.5.2.7) is
called for that array or until the lifetime of that array ends,
whichever happens first."

N.B.: Remove "non-constant" and change the leading "a" to "an"

Greetings from Bremen,

Daniel Kr   gler


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]