[libcxx-commits] [libcxx] 3ed8b93 - [libc++] Rename take_while_view::__sentinel to __take_while_view_sentinel

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jan 21 22:44:14 PST 2023


Author: Nikolas Klauser
Date: 2023-01-22T07:44:08+01:00
New Revision: 3ed8b93714c6ccd4ec282ab9cb68135bf1287c8a

URL: https://github.com/llvm/llvm-project/commit/3ed8b93714c6ccd4ec282ab9cb68135bf1287c8a
DIFF: https://github.com/llvm/llvm-project/commit/3ed8b93714c6ccd4ec282ab9cb68135bf1287c8a.diff

LOG: [libc++] Rename take_while_view::__sentinel to __take_while_view_sentinel

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

Reviewed By: var-const, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D142276

Added: 
    

Modified: 
    libcxx/include/__ranges/take_while_view.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__ranges/take_while_view.h b/libcxx/include/__ranges/take_while_view.h
index 77d7390dceb9c..59c0a4f82889a 100644
--- a/libcxx/include/__ranges/take_while_view.h
+++ b/libcxx/include/__ranges/take_while_view.h
@@ -53,11 +53,17 @@ template <class _View, class _Pred>
 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 @@ class take_while_view : public view_interface<take_while_view<_View, _Pred>> {
 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);
   }
 };


        


More information about the libcxx-commits mailing list