Title
copyable-box should be fully constexpr
Status
c++23
Section
[range.move.wrap]
Submitter
Tim Song

Created on 2021-06-19.00:00:00 last changed 5 months ago

Messages

Date: 2021-10-14.09:56:08

Proposed resolution:

This wording is relative to N4892.

  1. Modify [range.copy.wrap] as indicated:

    -1- Many types in this subclause are specified in terms of an exposition-only class template copyable-box. copyable-box<T> behaves exactly like optional<T> with the following differences:

    1. (1.1) — […]

    2. (1.2) — […]

    3. (1.3) — If copyable<T> is not modeled, the copy assignment operator is equivalent to:

      constexpr copyable-box& operator=(const copyable-box& that)
        noexcept(is_nothrow_copy_constructible_v<T>) {
        if (this != addressof(that)) {
          if (that) emplace(*that);
          else reset();
        }
        return *this;
      }
      
    4. (1.4) — If movable<T> is not modeled, the move assignment operator is equivalent to:

      constexpr copyable-box& operator=(copyable-box&& that)
        noexcept(is_nothrow_move_constructible_v<T>) {
        if (this != addressof(that)) {
          if (that) emplace(std::move(*that));
          else reset();
        }
        return *this;
      }
      
Date: 2021-10-14.00:00:00

[ 2021-10-14 Approved at October 2021 virtual plenary. Status changed: Voting → WP. ]

Date: 2021-06-15.00:00:00

[ 2021-06-23; Reflector poll ]

Set status to Tentatively Ready after eight votes in favour during reflector poll.

Date: 2021-06-19.00:00:00

P2231R1 made optional fully constexpr, but missed its cousin semiregular-box (which was renamed to copyable-box by P2325R3). Most operations of copyable-box are already constexpr simply because copyable-box is specified in terms of optional; the only missing ones are the assignment operators layered on top when the wrapped type isn't assignable itself.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2021-10-14 09:56:08adminsetmessages: + msg12134
2021-10-14 09:56:08adminsetstatus: voting -> wp
2021-09-29 12:57:28adminsetstatus: ready -> voting
2021-06-23 14:16:45adminsetmessages: + msg11967
2021-06-23 14:16:45adminsetstatus: new -> ready
2021-06-19 19:19:33adminsetmessages: + msg11947
2021-06-19 00:00:00admincreate