CopyConstructible doesn't preserve source values
Casey Carter

Created on 2018-07-07.00:00:00, last changed 2018-11-27.04:34:19.


Date: 2018-11-27.04:34:19

Proposed resolution:

This wording is relative to N4762.

Change [concept.copyconstructible] as indicated:

template<class T>
  concept CopyConstructible =
    MoveConstructible<T> &&
    Constructible<T, T&> && ConvertibleTo<T&, T> &&
    Constructible<T, const T&> && ConvertibleTo<const T&, T> &&
    Constructible<T, const T> && ConvertibleTo<const T, T>;

-1- If T is an object type, then let v be an lvalue of type (possibly const) T or an rvalue of type const T. CopyConstructible<T> is satisfied only if

(1.1) — After the definition T u = v;, u is equal to v and v is unmodified.

(1.2) — T(v) is equal to v and does not modify v.

Date: 2018-11-27.04:34:19

[ 2018-11 Reflector prioritization ]

Set Priority to 2

Date: 2018-07-07.00:00:00

The design intent of the CopyConstructible concept has always been that the source of the constructions it requires be left unmodified. Before P0541R1 reformulated the Constructible concept in terms of is_constructible, the wording which is now in [concepts.equality]/5:

This document uses a notational convention to specify which expressions declared in a requires-expression modify which inputs: except where otherwise specified, […] Operands that are constant lvalues or rvalues are required to not be modified.
indirectly enforced that requirement. Unfortunately, nothing in the current wording in [concept.copyconstructible] enforces that requirement.

Date User Action Args
2018-11-27 04:34:19adminsetmessages: + msg10234
2018-07-11 01:39:39adminsetmessages: + msg10026
2018-07-07 00:00:00admincreate