indirectly_readable_traits ambiguity for types with both value_type and element_type
Casey Carter

Created on 2020-05-15.00:00:00 last changed 1 week ago


Date: 2020-05-16.18:14:34

Proposed resolution:

This wording is relative to N4861.

  1. Modify [readable.traits] as indicated:

    template<class> struct cond-value-type { }; // exposition only
    template<class T>
      requires is_object_v<T>
    struct cond-value-type<T> {
      using value_type = remove_cv_t<T>;
    template<class> struct indirectly_readable_traits { };
    template<class T>
      requires requires { typename T::value_type; }
    struct indirectly_readable_traits<T>
      : cond-value-type<typename T::value_type> { };
    template<class T>
      requires requires { typename T::element_type; }
    struct indirectly_readable_traits<T>
      : cond-value-type<typename T::element_type> { };
    template<class T>
      requires requires {
        typename T::element_type;
        typename T::value_type;
        requires same_as<
          remove_cv_t<typename T::element_type>,
          remove_cv_t<typename T::value_type>>;
    struct indirectly_readable_traits<T>
      : cond-value-type<typename T::value_type> { };
Date: 2020-05-15.00:00:00

Per [readable.traits], indirectly_readable_traits<T>::value_type is the same type as remove_cv_t<T::value_type> if it denotes an object type, or remove_cv_t<T::element_type> if it denotes an object type. If both T::value_type and T::element_type denote types, indirectly_readable_traits<T>::value_type is ill-formed. This was perhaps not the best design, given that there are iterators in the wild (Boost's unordered containers) that define both nested types. indirectly_readable_traits should tolerate iterators that define both nested types consistently.

Date User Action Args
2020-05-16 18:14:34adminsetmessages: + msg11305
2020-05-15 00:00:00admincreate