Title
`constant_wrapper` wording problems
Status
ready
Section
[const.wrap.class]
Submitter
Matthias Wippich

Created on 2026-01-07.00:00:00 last changed 5 days ago

Messages

Date: 2026-01-16.22:12:42

Proposed resolution:

This wording is relative to N5032.

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

    struct cw-operators { // exposition only// pseudo-mutators
      template<constexpr-param T>
        constexpr auto operator++(this T) noexcept
          -> constant_wrapper<++Y (++T::value)> { return {}; }
      template<constexpr-param T>
        constexpr auto operator++(this T, int) noexcept
          -> constant_wrapper<Y++ (T::value++)> { return {}; }
      template<constexpr-param T>
        constexpr auto operator--(this T) noexcept
          -> constant_wrapper<--Y (--T::value)> { return {}; }
      template<constexpr-param T>
        constexpr auto operator--(this T, int) noexcept
          -> constant_wrapper<Y-- (T::value--)> { return {}; }
      …
    };
    
    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<(X = R::value)> { return {}; }
      constexpr operator decltype(auto)() const noexcept { return value; }
    };
    
Date: 2026-01-15.00:00:00

[ 2026-01-16; Reflector poll. ]

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

Date: 2026-01-07.00:00:00

During resolution of LWG 4383 prefix and postfix increment and decrement operators were changed to

template<constexpr-param T>
  constexpr auto operator++(this T) noexcept -> constant_wrapper<++Y>
    { return {}; }
template<constexpr-param T>
  constexpr auto operator++(this T, int) noexcept ->
    constant_wrapper<Y++> { return {}; }
template<constexpr-param T>
  constexpr auto operator--(this T) noexcept -> constant_wrapper<--Y>
    { return {}; }
template<constexpr-param T>
  constexpr auto operator--(this T, int) noexcept ->
    constant_wrapper<Y--> { return {}; }

However, we do not actually specify what `Y` is. Additionally, the assignment operator has been changed to

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

This is grammatically not valid C++. The assignment must be parenthesized.

History
Date User Action Args
2026-01-16 22:12:42adminsetmessages: + msg15872
2026-01-16 22:12:42adminsetstatus: new -> ready
2026-01-07 09:22:52adminsetmessages: + msg15846
2026-01-07 00:00:00admincreate