Created on 2021-05-09.00:00:00 last changed 12 months ago
Proposed resolution:
This wording is relative to N4885.
Modify [range.view] as indicated:
template<class T> inline constexpr bool is-derived-from-view-interface = see below; // exposition only template<class T> inline constexpr bool enable_view = derived_from<T, view_base> || is-derived-from-view-interface<T>;-?- For a type T, is-derived-from-view-interface<T> is true if and only if T has exactly one public base class view_interface<U> for some type U and T has no base classes of type view_interface<V> for any other type V.
-5- Remarks: Pursuant to [namespace.std], users may specialize enable_view to true for cv-unqualified program-defined types which model view, and false for types which do not. Such specializations shall be usable in constant expressions ([expr.const]) and have type const bool.
Modify [view.interface.general] as indicated:
namespace std::ranges { template<class D> requires is_class_v<D> && same_as<D, remove_cv_t<D>> class view_interface: public view_base{ […] }; }
[ 2021-06-07 Approved at June 2021 virtual plenary. Status changed: Voting → WP. ]
[ 2021-05-26; Reflector poll ]
Set status to Tentatively Ready after five votes in favour during reflector poll.
[ 2021-05-17; Reflector poll ]
Priority set to 2.
view_interface<D> is currently specified to publicly derive from view_base. This derivation requires unnecessary padding in range adaptors like reverse_view<V>: the view_base subobject of the reverse_view is required to reside at a different address than the view_base subobject of V (assuming that V similarly opted into being a view through derivation from view_interface or view_base).
This appears to be a case of overspecification: we want public and unambiguous derivation from view_interface to make the class a view; the exact mechanism of how that opt-in is accomplished should have been left as an implementation detail. The proposed resolution below has been implemented on top of libstdc++ master and passes its ranges testsuite, with the exception of a test that checks for the size of various range adaptors (and therefore asserts the existence of view_base-induced padding).History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2021-06-07 16:58:04 | admin | set | messages: + msg11912 |
2021-06-07 16:58:04 | admin | set | status: voting -> wp |
2021-05-26 21:11:22 | admin | set | status: ready -> voting |
2021-05-26 10:53:33 | admin | set | messages: + msg11857 |
2021-05-26 10:53:33 | admin | set | status: new -> ready |
2021-05-17 12:23:56 | admin | set | messages: + msg11805 |
2021-05-09 21:46:47 | admin | set | messages: + msg11793 |
2021-05-09 00:00:00 | admin | create |