3374. P0653 + P1006 should have made the other std::to_address overload constexpr

Section: 20.2.4 [pointer.conversion] Status: C++20 Submitter: Billy O'Neal III Opened: 2020-01-14 Last modified: 2021-02-25 10:48:01 UTC

Priority: 0

View all issues with C++20 status.


While reviewing some interactions with P0653 + P1006, Billy discovered that one of the overloads was missing the constexpr tag. This might be a typo or a missed merge interaction between P0653 (which adds to_address with the pointer overload being constexpr) and P1006 (which makes pointer_traits::pointer_to constexpr). Mail was sent the LWG reflector, and Glen Fernandes, the author of P0653, indicates that this might have been an oversight.

[2020-02-01 Status set to Tentatively Ready after seven positive votes on the reflector.]

Proposed resolution:

This wording is relative to N4842.

  1. Modify 20.2.2 [memory.syn], header <memory> synopsis, as indicated:

    // 20.2.4 [pointer.conversion], pointer conversion
    template<class T>
      constexpr T* to_address(T* p) noexcept;
    template<class Ptr>
      constexpr auto to_address(const Ptr& p) noexcept;
  2. Modify 20.2.4 [pointer.conversion] as indicated:

    template<class Ptr> constexpr auto to_address(const Ptr& p) noexcept;

    -3- Returns: pointer_traits<Ptr>::to_address(p) if that expression is well-formed (see [pointer.traits.optmem]), otherwise to_address(p.operator->()).