Title
`constant_wrapper` should assign to `value`
Status
ready
Section
[const.wrap.class]
Submitter
Tomasz KamiƄski

Created on 2026-02-17.00:00:00 last changed 1 week ago

Messages

Date: 2026-02-27.16:05:19

Proposed resolution:

This wording is relative to N5032 with changes from 4500.

  1. Modify [const.wrap.class], class template `constant_wrapper` synopsis, as indicated:

    template<cw-fixed-value X, class>
    struct constant_wrapper : cw-operators {
      static constexpr const auto & value = X.data;
      using type = constant_wrapper;
      using value_type = decltype(X)::type;
    
      template<constexpr-param R>
        constexpr auto operator=(R) const noexcept
      -> constant_wrapper<(valueX = R::value)> { return {}; }
    
      constexpr operator decltype(auto)() const noexcept { return value; }
    };
    
Date: 2026-02-15.00:00:00

[ 2026-02-27; Reflector poll. ]

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

Date: 2026-02-17.00:00:00

During resolution of LWG 4383 assignment operator of constant_wrapper, was changed to:

template<constexpr-param R>
  constexpr auto operator=(R) const noexcept -> constant_wrapper<X = R::value> { return {}; }

This is incorrect (and inconsistent with other operators), as we assign to `X` that is object of specialization of exposition only cw-fixed-value, instead of `value`.

History
Date User Action Args
2026-02-27 16:05:19adminsetmessages: + msg15979
2026-02-27 16:05:19adminsetstatus: new -> ready
2026-02-17 17:39:09adminsetmessages: + msg15932
2026-02-17 00:00:00admincreate