[libcxx-commits] [PATCH] D142276: [libc++] Rename take_while_view::__sentinel to __take_while_view_sentinel

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 20 23:35:27 PST 2023


philnik created this revision.
philnik added reviewers: ldionne, Mordante, var-const, huixie90.
Herald added a project: All.
philnik requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

This makes it easier to specialize traits classes, like __segmented_iterator_traits.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142276

Files:
  libcxx/include/__ranges/take_while_view.h


Index: libcxx/include/__ranges/take_while_view.h
===================================================================
--- libcxx/include/__ranges/take_while_view.h
+++ libcxx/include/__ranges/take_while_view.h
@@ -53,11 +53,17 @@
 concept __take_while_const_is_range =
     range<const _View> && indirect_unary_predicate<const _Pred, iterator_t<const _View>>;
 
+template <class, class, bool>
+class __take_while_view_sentinel;
+
 template <view _View, class _Pred>
   requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>>
 class take_while_view : public view_interface<take_while_view<_View, _Pred>> {
-  template <bool>
-  class __sentinel;
+  template <class, class, bool>
+  friend class __take_while_view_sentinel;
+
+  template <bool _Const>
+  using __sentinel = __take_while_view_sentinel<_View, _Pred, _Const>;
 
   _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
   _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Pred> __pred_;
@@ -108,37 +114,37 @@
 template <class _Range, class _Pred>
 take_while_view(_Range&&, _Pred) -> take_while_view<views::all_t<_Range>, _Pred>;
 
-template <view _View, class _Pred>
-  requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>>
-template <bool _Const>
-class take_while_view<_View, _Pred>::__sentinel {
+template <class _View, class _Pred, bool _Const>
+class __take_while_view_sentinel {
   using _Base = __maybe_const<_Const, _View>;
 
   sentinel_t<_Base> __end_ = sentinel_t<_Base>();
   const _Pred* __pred_     = nullptr;
 
-  friend class __sentinel<!_Const>;
+  template <class, class, bool>
+  friend class __take_while_view_sentinel;
 
 public:
-  _LIBCPP_HIDE_FROM_ABI __sentinel() = default;
+  _LIBCPP_HIDE_FROM_ABI __take_while_view_sentinel() = default;
 
-  _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(sentinel_t<_Base> __end, const _Pred* __pred)
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit __take_while_view_sentinel(sentinel_t<_Base> __end, const _Pred* __pred)
       : __end_(std::move(__end)), __pred_(__pred) {}
 
-  _LIBCPP_HIDE_FROM_ABI constexpr __sentinel(__sentinel<!_Const> __s)
+  _LIBCPP_HIDE_FROM_ABI constexpr __take_while_view_sentinel(__take_while_view_sentinel<_View, _Pred, !_Const> __s)
     requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
       : __end_(std::move(__s.__end_)), __pred_(__s.__pred_) {}
 
   _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Base> base() const { return __end_; }
 
-  _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const iterator_t<_Base>& __x, const __sentinel& __y) {
+  _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+  operator==(const iterator_t<_Base>& __x, const __take_while_view_sentinel& __y) {
     return __x == __y.__end_ || !std::invoke(*__y.__pred_, *__x);
   }
 
   template <bool _OtherConst = !_Const>
     requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
   _LIBCPP_HIDE_FROM_ABI friend constexpr bool
-  operator==(const iterator_t<__maybe_const<_OtherConst, _View>>& __x, const __sentinel& __y) {
+  operator==(const iterator_t<__maybe_const<_OtherConst, _View>>& __x, const __take_while_view_sentinel& __y) {
     return __x == __y.__end_ || !std::invoke(*__y.__pred_, *__x);
   }
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142276.491043.patch
Type: text/x-patch
Size: 3306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230121/220ae87e/attachment.bin>


More information about the libcxx-commits mailing list