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.
Section: 29.6 [numarray] Status: CD1 Submitter: Martin Sebor Opened: 2007-01-20 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [numarray].
View all issues with CD1 status.
Discussion:
The computed and "fill" assignment operators of valarray
helper array class templates (slice_array
,
gslice_array
, mask_array
, and
indirect_array
) are const member functions of each class
template (the latter by the resolution of 123(i)
since they have reference semantics and thus do not affect
the state of the object on which they are called. However, the copy
assignment operators of these class templates, which also have
reference semantics, are non-const. The absence of constness opens
the door to speculation about whether they really are intended to have
reference semantics (existing implementations vary widely).
Pre-Kona, Martin adds:
I realized that adding the const qualifier to the functions as I suggested would break the const correctness of the classes. A few possible solutions come to mind:
Proposed resolution:
Declare the copy assignment operators of all four helper array class templates const.
Specifically, make the following edits:
Change the signature in 29.6.5 [template.slice.array] and 29.6.5.2 [slice.arr.assign] as follows:
const slice_array& operator= (const slice_array&) const;
Change the signature in 29.6.7 [template.gslice.array] and 29.6.7.2 [gslice.array.assign] as follows:
const gslice_array& operator= (const gslice_array&) const;
Change the signature in 29.6.8 [template.mask.array] and 29.6.8.2 [mask.array.assign] as follows:
const mask_array& operator= (const mask_array&) const;
Change the signature in 29.6.9 [template.indirect.array] and 29.6.9.2 [indirect.array.assign] as follows:
const indirect_array& operator= (const indirect_array&) const;
[ Kona (2007) Added const qualification to the return types and set to Ready. ]