[libcxx-commits] [PATCH] D117714: [WIP][libc++] Implement LWG3549: view_interface need not inherit from view_base

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 19 12:27:47 PST 2022


jloser created this revision.
jloser added reviewers: ldionne, Quuxplusone, CaseyCarter, Mordante.
jloser requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

WIP as I don't think this covers some cases for if the type has an inheritance
chain where it inherits multiple times from `view_interface`. `enable_view`
should require one and only one public base class for `view_interface<U>`, and
we'll need to add coverage for that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117714

Files:
  libcxx/docs/Status/Cxx2bIssues.csv
  libcxx/include/__ranges/enable_view.h
  libcxx/include/__ranges/view_interface.h
  libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp


Index: libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp
===================================================================
--- libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp
+++ libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp
@@ -32,8 +32,6 @@
 static_assert(!ValidViewInterfaceType<Empty &>);
 static_assert( ValidViewInterfaceType<Empty>);
 
-static_assert(std::derived_from<std::ranges::view_interface<Empty>, std::ranges::view_base>);
-
 using InputIter = cpp20_input_iterator<const int*>;
 
 struct InputRange : std::ranges::view_interface<InputRange> {
Index: libcxx/include/__ranges/view_interface.h
===================================================================
--- libcxx/include/__ranges/view_interface.h
+++ libcxx/include/__ranges/view_interface.h
@@ -40,7 +40,7 @@
 
 template<class _Derived>
   requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
-class view_interface : public view_base {
+class view_interface {
   _LIBCPP_HIDE_FROM_ABI
   constexpr _Derived& __derived() noexcept {
     static_assert(sizeof(_Derived) && derived_from<_Derived, view_interface> && view<_Derived>);
Index: libcxx/include/__ranges/enable_view.h
===================================================================
--- libcxx/include/__ranges/enable_view.h
+++ libcxx/include/__ranges/enable_view.h
@@ -25,8 +25,12 @@
 
 struct view_base { };
 
+template<class _Derived>
+  requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
+class view_interface;
+
 template <class _Tp>
-inline constexpr bool enable_view = derived_from<_Tp, view_base>;
+inline constexpr bool enable_view = derived_from<_Tp, view_base> || derived_from<_Tp, view_interface<_Tp>>;
 
 } // end namespace ranges
 
Index: libcxx/docs/Status/Cxx2bIssues.csv
===================================================================
--- libcxx/docs/Status/Cxx2bIssues.csv
+++ libcxx/docs/Status/Cxx2bIssues.csv
@@ -91,7 +91,7 @@
 `3544 <https://wg21.link/LWG3544>`__,"``format-arg-store::args`` is unintentionally not exposition-only","June 2021","","","|format|"
 `3546 <https://wg21.link/LWG3546>`__,"``common_iterator``'s postfix-proxy is not quite right","June 2021","","","|ranges|"
 `3548 <https://wg21.link/LWG3548>`__,"``shared_ptr`` construction from ``unique_ptr`` should move (not copy) the deleter","June 2021","",""
-`3549 <https://wg21.link/LWG3549>`__,"``view_interface`` is overspecified to derive from ``view_base``","June 2021","","","|ranges|"
+`3549 <https://wg21.link/LWG3549>`__,"``view_interface`` is overspecified to derive from ``view_base``","June 2021","|Complete|","14.0","|ranges|"
 `3551 <https://wg21.link/LWG3551>`__,"``borrowed_{iterator,subrange}_t`` are overspecified","June 2021","","","|ranges|"
 `3552 <https://wg21.link/LWG3552>`__,"Parallel specialized memory algorithms should require forward iterators","June 2021","",""
 `3553 <https://wg21.link/LWG3553>`__,"Useless constraint in ``split_view::outer-iterator::value_type::begin()``","June 2021","","","|ranges|"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117714.401370.patch
Type: text/x-patch
Size: 3092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220119/c2f37d2a/attachment.bin>


More information about the libcxx-commits mailing list