This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

3812. [fund.ts.v3] Incorrect constraint on propagate_const conversion function

Section: 3.2.2.5 [fund.ts.v3::propagate_const.const_observers] Status: New Submitter: Giuseppe D'Angelo Opened: 2022-11-04 Last modified: 2022-11-12

Priority: 3

View all issues with New status.

Discussion:

Addresses: fund.ts.v3

This issue has its origin in the discussion of gcc issue 107525.

The current draft of LFTSv3 specifies this conversion function for propagate_const in 3.2.2.5 [fund.ts.v3::propagate_const.const_observers]:

constexpr operator const element_type*() const;

-7- Returns: get().

-8- Remarks: This function shall not participate in overload resolution unless T is an object pointer type or has an implicit conversion to const element_type*.

The constraint should however specify that const T (and not T) needs to have an implicit conversion to const element_type *.

Basically: if const T cannot do the conversion, then neither const propagate_const<T> should be able to.

One can design a type X such as a const X cannot convert to const element_type * (for instance, by =deleteing the corresponding conversion function). If now one asks whether const propagate_const<X> is convertible to const element_type *, the answer is (surprisingly) "yes".

[Kona 2022-11-12; Set priority to 3]

Proposed resolution:

This wording is relative to N4840.

  1. Modify 3.2.2.5 [fund.ts.v3::propagate_const.const_observers] as indicated:

    constexpr operator const element_type*() const;
    

    -7- Returns: get().

    -8- Remarks: This function shall not participate in overload resolution unless T is an object pointer type or const T has an implicit conversion to const element_type*.