[libcxx-commits] [libcxx] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 6 13:13:35 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 48ca868dd3f803cd8c500475e5880652bad75815 b3de573887cdd86fd6ce168bdcc6d729d73b13b2 -- libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp libcxx/include/__ranges/take_view.h libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/__ranges/take_view.h b/libcxx/include/__ranges/take_view.h
index 811428e529..518375d684 100644
--- a/libcxx/include/__ranges/take_view.h
+++ b/libcxx/include/__ranges/take_view.h
@@ -180,10 +180,9 @@ public:
return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
}
- template<bool _OtherConst = !_Const>
+ 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 _Iter<_OtherConst>& __lhs, const __sentinel& __rhs) {
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const _Iter<_OtherConst>& __lhs, const __sentinel& __rhs) {
return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
}
};
diff --git a/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
index 9d1bdaa82d..8928371939 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
@@ -34,14 +34,14 @@ constexpr bool test() {
{
// Test the conversion from "sentinel" to "sentinel-to-const".
- using TakeView = std::ranges::take_view<MoveOnlyView>;
- using Sentinel = std::ranges::sentinel_t<TakeView>;
+ using TakeView = std::ranges::take_view<MoveOnlyView>;
+ using Sentinel = std::ranges::sentinel_t<TakeView>;
using ConstSentinel = std::ranges::sentinel_t<const TakeView>;
static_assert(std::is_convertible_v<Sentinel, ConstSentinel>);
- TakeView tv = TakeView(MoveOnlyView(buffer), 4);
- Sentinel s = tv.end();
+ TakeView tv = TakeView(MoveOnlyView(buffer), 4);
+ Sentinel s = tv.end();
ConstSentinel cs = s;
- cs = s; // test assignment also
+ cs = s; // test assignment also
assert(tv.begin() + 4 == s);
assert(tv.begin() + 4 == cs);
assert(std::as_const(tv).begin() + 4 == s);
@@ -50,12 +50,12 @@ constexpr bool test() {
{
// Test the constructor from "base-sentinel" to "sentinel".
- using TakeView = std::ranges::take_view<MoveOnlyView>;
- using Sentinel = std::ranges::sentinel_t<TakeView>;
+ using TakeView = std::ranges::take_view<MoveOnlyView>;
+ using Sentinel = std::ranges::sentinel_t<TakeView>;
sentinel_wrapper<int*> sw1 = MoveOnlyView(buffer).end();
- static_assert( std::is_constructible_v<Sentinel, sentinel_wrapper<int*>>);
+ static_assert(std::is_constructible_v<Sentinel, sentinel_wrapper<int*>>);
static_assert(!std::is_convertible_v<sentinel_wrapper<int*>, Sentinel>);
- auto s = Sentinel(sw1);
+ auto s = Sentinel(sw1);
std::same_as<sentinel_wrapper<int*>> auto sw2 = s.base();
assert(base(sw2) == base(sw1));
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/74655
More information about the libcxx-commits
mailing list