Issue 3541: indirectly_readable_traits should be SFINAE-friendly for all types (original) (raw)


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

3541. indirectly_readable_traits should be SFINAE-friendly for all types

Section: 24.3.2.2 [readable.traits] Status: C++23 Submitter: Christopher Di Bella Opened: 2021-04-08 Last modified: 2023-11-22

Priority: Not Prioritized

View all other issues in [readable.traits].

View all issues with C++23 status.

Discussion:

Following the outcome of LWG 3446(i), a strict implementation of std::indirectly_readable_traitsisn't SFINAE-friendly for types that have different value_type and element_type members due to the ambiguity between the _has-member-value-type_ and _has-member-element-type_specialisations. Other traits types are empty when requirements aren't met; we should follow suit here.

[2021-04-20; Reflector poll]

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

[2021-06-07 Approved at June 2021 virtual plenary. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4885.

  1. Modify 24.3.2.2 [readable.traits] p1 as indicated:

    […]
    template
    concept has-member-value-type = requires { typename T::value_type; }; // exposition only

    template
    concept has-member-element-type = requires { typename T::element_type; }; // exposition only

    template struct indirectly_readable_traits { };

    […]

    template<_has-member-value-type_ T>
    struct indirectly_readable_traits
    : cond-value-type { };

    template<_has-member-element-type_ T>
    struct indirectly_readable_traits
    : cond-value-type { };

    template<_has-member-value-type_ T>
    requires has-member-element-type
    struct indirectly_readable_traits { };

    template<_has-member-value-type_ T>
    requires has-member-element-type &&
    same_as<remove_cv_t, remove_cv_t>

struct indirectly_readable_traits
: cond-value-type { };
[…]