Title
CopyConstructible doesn't preserve source values
Status
c++20
Section
[concepts.object]
Submitter
Casey Carter

Created on 2018-07-07.00:00:00 last changed 46 months ago

Messages

Date: 2020-02-14.09:37:04

Proposed resolution:

This wording is relative to N4849.

Change [concept.copyconstructible] as indicated:

template<class T>
  concept copy_constructible =
    move_constructible<T> &&
    constructible_from<T, T&> && convertible_to<T&, T> &&
    constructible_from<T, const T&> && convertible_to<const T&, T> &&
    constructible_from<T, const T> && convertible_to<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. T models copy_constructible only if

(1.1) — After the definition T u = v;, u is equal to v ([concepts.equality]) and v is not modified.

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

Date: 2020-02-14.09:37:04

[ 2020-02 Status to Immediate on Thursday night in Prague. ]

Date: 2020-02-13.00:00:00

[ 2020-02-13 Per LWG review, Casey provides updated P/R wording. ]

Date: 2020-02-13.19:13:44

[ 2018-11 Reflector prioritization ]

Set Priority to 2

Previous resolution: [SUPERSEDED]

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-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.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: immediate -> wp
2020-02-14 09:37:04adminsetmessages: + msg11105
2020-02-14 09:37:04adminsetstatus: new -> immediate
2020-02-13 19:13:44adminsetmessages: + msg11081
2018-11-27 04:34:19adminsetmessages: + msg10234
2018-07-11 01:39:39adminsetmessages: + msg10026
2018-07-07 00:00:00admincreate