Skip to content

Commit 8c0a611

Browse files
authored
[libcxx][NFC] Rename iterator/sentinel type template parameter names (#76201)
According to internally agreed upon best practices, type template parameter names representing iterator types should be named `Iter`. For type template parameters representing sentinel types, they should be named `Sent`. Signed-off-by: Will Hawkins <[email protected]>
1 parent 181eab2 commit 8c0a611

File tree

12 files changed

+53
-53
lines changed

12 files changed

+53
-53
lines changed

libcxx/test/std/ranges/range.adaptors/range.chunk.by/range.chunk.by.iter/compare.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
#include "test_iterators.h"
2626
#include "test_macros.h"
2727

28-
template <class Iterator, class Sentinel = sentinel_wrapper<Iterator>>
28+
template <class Iter, class Sent = sentinel_wrapper<Iter>>
2929
constexpr void test() {
30-
using Underlying = View<Iterator, Sentinel>;
30+
using Underlying = View<Iter, Sent>;
3131
using ChunkByView = std::ranges::chunk_by_view<Underlying, std::ranges::less_equal>;
3232
using ChunkByIterator = std::ranges::iterator_t<ChunkByView>;
3333

3434
auto make_chunk_by_view = [](auto& arr) {
35-
View view{Iterator(arr.data()), Sentinel(Iterator(arr.data() + arr.size()))};
35+
View view{Iter(arr.data()), Sent(Iter(arr.data() + arr.size()))};
3636
return ChunkByView(std::move(view), std::ranges::less_equal{});
3737
};
3838

libcxx/test/std/ranges/range.adaptors/range.chunk.by/range.chunk.by.iter/decrement.pass.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ struct TrackingPred : TrackInitialization {
4242
constexpr bool operator()(int x, int y) const { return x <= y; }
4343
};
4444

45-
template <class Iterator, IsConst Constant, class Sentinel = sentinel_wrapper<Iterator>>
45+
template <class Iter, IsConst Constant, class Sent = sentinel_wrapper<Iter>>
4646
constexpr void test() {
47-
using Underlying = View<Iterator, Sentinel>;
47+
using Underlying = View<Iter, Sent>;
4848
using ChunkByView = std::ranges::chunk_by_view<Underlying, std::ranges::less_equal>;
4949
using ChunkByIterator = std::ranges::iterator_t<ChunkByView>;
5050

5151
static_assert(HasPostDecrement<ChunkByIterator>);
5252
static_assert(HasPreDecrement<ChunkByIterator>);
5353

5454
auto make_chunk_by_view = [](auto& arr) {
55-
View view{Iterator{arr.data()}, Sentinel{Iterator{arr.data() + arr.size()}}};
55+
View view{Iter{arr.data()}, Sent{Iter{arr.data() + arr.size()}}};
5656
return ChunkByView{std::move(view), std::ranges::less_equal{}};
5757
};
5858

@@ -125,7 +125,7 @@ constexpr void test() {
125125
// Test with a predicate that takes by non-const reference
126126
if constexpr (!std::to_underlying(Constant)) {
127127
std::array array{1, 2, 3, -3, -2, -1};
128-
View v{Iterator{array.data()}, Sentinel{Iterator{array.data() + array.size()}}};
128+
View v{Iter{array.data()}, Sent{Iter{array.data() + array.size()}}};
129129
auto view = std::views::chunk_by(std::move(v), [](int& x, int& y) { return x <= y; });
130130

131131
auto it = std::ranges::next(view.begin());
@@ -137,7 +137,7 @@ constexpr void test() {
137137
// Test with a predicate that is invocable but not callable (i.e. cannot be called like regular function 'f()')
138138
{
139139
std::array array = {1, 2, 3, -3, -2, -1};
140-
auto v = View{Iterator{array.data()}, Sentinel{Iterator{array.data() + array.size()}}} |
140+
auto v = View{Iter{array.data()}, Sent{Iter{array.data() + array.size()}}} |
141141
std::views::transform([](int x) { return IntWrapper{x}; });
142142
auto view = std::views::chunk_by(std::move(v), &IntWrapper::lessEqual);
143143

@@ -151,7 +151,7 @@ constexpr void test() {
151151
if constexpr (std::ranges::common_range<Underlying>) {
152152
bool moved = false, copied = false;
153153
std::array array{1, 2, 1, 3};
154-
View v{Iterator(array.data()), Sentinel(Iterator(array.data() + array.size()))};
154+
View v{Iter(array.data()), Sent(Iter(array.data() + array.size()))};
155155
auto view = std::views::chunk_by(std::move(v), TrackingPred(&moved, &copied));
156156
assert(std::exchange(moved, false));
157157
auto it = view.end();

libcxx/test/std/ranges/range.adaptors/range.filter/iterator/arrow.pass.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,22 @@ struct WithNonCopyableIterator : std::ranges::view_base {
7373
};
7474
static_assert(std::ranges::input_range<WithNonCopyableIterator>);
7575

76-
template <class Iterator, class Sentinel = sentinel_wrapper<Iterator>>
76+
template <class Iter, class Sent = sentinel_wrapper<Iter>>
7777
constexpr void test() {
7878
std::array<XYPoint, 5> array{{{0, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}}};
79-
using View = minimal_view<Iterator, Sentinel>;
79+
using View = minimal_view<Iter, Sent>;
8080
using FilterView = std::ranges::filter_view<View, AlwaysTrue>;
8181
using FilterIterator = std::ranges::iterator_t<FilterView>;
8282

8383
auto make_filter_view = [](auto begin, auto end, auto pred) {
84-
View view{Iterator(begin), Sentinel(Iterator(end))};
84+
View view{Iter(begin), Sent(Iter(end))};
8585
return FilterView(std::move(view), pred);
8686
};
8787

8888
for (std::ptrdiff_t n = 0; n != 5; ++n) {
8989
FilterView view = make_filter_view(array.data(), array.data() + array.size(), AlwaysTrue{});
90-
FilterIterator const iter(view, Iterator(array.data() + n));
91-
std::same_as<Iterator> decltype(auto) result = iter.operator->();
90+
FilterIterator const iter(view, Iter(array.data() + n));
91+
std::same_as<Iter> decltype(auto) result = iter.operator->();
9292
assert(base(result) == array.data() + n);
9393
assert(iter->x == n);
9494
assert(iter->y == n);

libcxx/test/std/ranges/range.adaptors/range.filter/iterator/base.pass.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
#include "test_macros.h"
2222
#include "../types.h"
2323

24-
template <class Iterator, class Sentinel = sentinel_wrapper<Iterator>>
24+
template <class Iter, class Sent = sentinel_wrapper<Iter>>
2525
constexpr void test() {
26-
using View = minimal_view<Iterator, Sentinel>;
26+
using View = minimal_view<Iter, Sent>;
2727
using FilterView = std::ranges::filter_view<View, AlwaysTrue>;
2828
using FilterIterator = std::ranges::iterator_t<FilterView>;
2929

3030
auto make_filter_view = [](auto begin, auto end, auto pred) {
31-
View view{Iterator(begin), Sentinel(Iterator(end))};
31+
View view{Iter(begin), Sent(Iter(end))};
3232
return FilterView(std::move(view), pred);
3333
};
3434

@@ -37,18 +37,18 @@ constexpr void test() {
3737

3838
// Test the const& version
3939
{
40-
FilterIterator const iter(view, Iterator(array.data()));
41-
Iterator const& result = iter.base();
42-
ASSERT_SAME_TYPE(Iterator const&, decltype(iter.base()));
40+
FilterIterator const iter(view, Iter(array.data()));
41+
Iter const& result = iter.base();
42+
ASSERT_SAME_TYPE(Iter const&, decltype(iter.base()));
4343
ASSERT_NOEXCEPT(iter.base());
4444
assert(base(result) == array.data());
4545
}
4646

4747
// Test the && version
4848
{
49-
FilterIterator iter(view, Iterator(array.data()));
50-
Iterator result = std::move(iter).base();
51-
ASSERT_SAME_TYPE(Iterator, decltype(std::move(iter).base()));
49+
FilterIterator iter(view, Iter(array.data()));
50+
Iter result = std::move(iter).base();
51+
ASSERT_SAME_TYPE(Iter, decltype(std::move(iter).base()));
5252
assert(base(result) == array.data());
5353
}
5454
}

libcxx/test/std/ranges/range.adaptors/range.filter/iterator/ctor.parent_iter.pass.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
#include "test_iterators.h"
1919
#include "../types.h"
2020

21-
template <class Iterator, class Sentinel = sentinel_wrapper<Iterator>>
21+
template <class Iter, class Sent = sentinel_wrapper<Iter>>
2222
constexpr void test() {
23-
using View = minimal_view<Iterator, Sentinel>;
23+
using View = minimal_view<Iter, Sent>;
2424
using FilterView = std::ranges::filter_view<View, AlwaysTrue>;
2525
using FilterIterator = std::ranges::iterator_t<FilterView>;
2626

2727
std::array<int, 10> array{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
28-
View view(Iterator(array.data()), Sentinel(Iterator(array.data() + array.size())));
29-
Iterator iter = view.begin();
28+
View view(Iter(array.data()), Sent(Iter(array.data() + array.size())));
29+
Iter iter = view.begin();
3030

3131
FilterView filter_view(std::move(view), AlwaysTrue{});
3232
FilterIterator filter_iter(filter_view, std::move(iter));

libcxx/test/std/ranges/range.adaptors/range.filter/iterator/decrement.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ using FilterIteratorFor = std::ranges::iterator_t<
3838
std::ranges::filter_view<minimal_view<Iterator, sentinel_wrapper<Iterator>>, EqualTo>
3939
>;
4040

41-
template <class Iterator, class Sentinel = sentinel_wrapper<Iterator>>
41+
template <class Iter, class Sent = sentinel_wrapper<Iter>>
4242
constexpr void test() {
43-
using View = minimal_view<Iterator, Sentinel>;
43+
using View = minimal_view<Iter, Sent>;
4444
using FilterView = std::ranges::filter_view<View, EqualTo>;
4545
using FilterIterator = std::ranges::iterator_t<FilterView>;
4646

4747
auto make_filter_view = [](auto begin, auto end, auto pred) {
48-
View view{Iterator(begin), Sentinel(Iterator(end))};
48+
View view{Iter(begin), Sent(Iter(end))};
4949
return FilterView(std::move(view), pred);
5050
};
5151

libcxx/test/std/ranges/range.adaptors/range.filter/iterator/deref.pass.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
#include "test_macros.h"
2222
#include "../types.h"
2323

24-
template <class Iterator, class ValueType = int, class Sentinel = sentinel_wrapper<Iterator>>
24+
template <class Iter, class ValueType = int, class Sent = sentinel_wrapper<Iter>>
2525
constexpr void test() {
26-
using View = minimal_view<Iterator, Sentinel>;
26+
using View = minimal_view<Iter, Sent>;
2727
using FilterView = std::ranges::filter_view<View, AlwaysTrue>;
2828
using FilterIterator = std::ranges::iterator_t<FilterView>;
2929

3030
auto make_filter_view = [](auto begin, auto end, auto pred) {
31-
View view{Iterator(begin), Sentinel(Iterator(end))};
31+
View view{Iter(begin), Sent(Iter(end))};
3232
return FilterView(std::move(view), pred);
3333
};
3434

3535
std::array array{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
3636
FilterView view = make_filter_view(array.data(), array.data() + array.size(), AlwaysTrue{});
3737

3838
for (std::size_t n = 0; n != array.size(); ++n) {
39-
FilterIterator const iter(view, Iterator(array.data() + n));
39+
FilterIterator const iter(view, Iter(array.data() + n));
4040
ValueType& result = *iter;
4141
ASSERT_SAME_TYPE(ValueType&, decltype(*iter));
4242
assert(&result == array.data() + n);

libcxx/test/std/ranges/range.adaptors/range.filter/sentinel/base.pass.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@
1919
#include "test_iterators.h"
2020
#include "../types.h"
2121

22-
template <class Iterator, class Sentinel = sentinel_wrapper<Iterator>>
22+
template <class Iter, class Sent = sentinel_wrapper<Iter>>
2323
constexpr void test() {
24-
using View = minimal_view<Iterator, Sentinel>;
24+
using View = minimal_view<Iter, Sent>;
2525
using FilterView = std::ranges::filter_view<View, AlwaysTrue>;
2626
using FilterSentinel = std::ranges::sentinel_t<FilterView>;
2727

2828
auto make_filter_view = [](auto begin, auto end, auto pred) {
29-
View view{Iterator(begin), Sentinel(Iterator(end))};
29+
View view{Iter(begin), Sent(Iter(end))};
3030
return FilterView(std::move(view), pred);
3131
};
3232

3333
std::array<int, 5> array{0, 1, 2, 3, 4};
3434
FilterView view = make_filter_view(array.data(), array.data() + array.size(), AlwaysTrue{});
3535

3636
FilterSentinel const sent = view.end();
37-
std::same_as<Sentinel> decltype(auto) result = sent.base();
37+
std::same_as<Sent> decltype(auto) result = sent.base();
3838
assert(base(base(result)) == array.data() + array.size());
3939
}
4040

libcxx/test/std/ranges/range.adaptors/range.filter/sentinel/compare.pass.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@
1919
#include "test_iterators.h"
2020
#include "../types.h"
2121

22-
template <class Iterator, class Sentinel = sentinel_wrapper<Iterator>>
22+
template <class Iter, class Sent = sentinel_wrapper<Iter>>
2323
constexpr void test() {
24-
using View = minimal_view<Iterator, Sentinel>;
24+
using View = minimal_view<Iter, Sent>;
2525

2626
std::array<int, 5> array{0, 1, 2, 3, 4};
2727

2828
{
29-
View v(Iterator(array.data()), Sentinel(Iterator(array.data() + array.size())));
29+
View v(Iter(array.data()), Sent(Iter(array.data() + array.size())));
3030
std::ranges::filter_view view(std::move(v), AlwaysTrue{});
3131
auto const it = view.begin();
3232
auto const sent = view.end();
3333
std::same_as<bool> decltype(auto) result = (it == sent);
3434
assert(!result);
3535
}
3636
{
37-
View v(Iterator(array.data()), Sentinel(Iterator(array.data() + array.size())));
37+
View v(Iter(array.data()), Sent(Iter(array.data() + array.size())));
3838
std::ranges::filter_view view(std::move(v), [](auto) { return false; });
3939
auto const it = view.begin();
4040
auto const sent = view.end();

libcxx/test/std/ranges/range.adaptors/range.filter/sentinel/ctor.default.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#include "test_iterators.h"
1717
#include "../types.h"
1818

19-
template <class Iterator, class Sentinel = sentinel_wrapper<Iterator>>
19+
template <class Iter, class Sent = sentinel_wrapper<Iter>>
2020
constexpr void test() {
21-
using View = minimal_view<Iterator, Sentinel>;
21+
using View = minimal_view<Iter, Sent>;
2222
using FilterView = std::ranges::filter_view<View, AlwaysTrue>;
2323
using FilterSentinel = std::ranges::sentinel_t<FilterView>;
2424
FilterSentinel sent1{};

libcxx/test/std/ranges/range.adaptors/range.filter/sentinel/ctor.parent.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
#include "test_iterators.h"
2020
#include "../types.h"
2121

22-
template <class Iterator, class Sentinel = sentinel_wrapper<Iterator>>
22+
template <class Iter, class Sent = sentinel_wrapper<Iter>>
2323
constexpr void test() {
24-
using View = minimal_view<Iterator, Sentinel>;
24+
using View = minimal_view<Iter, Sent>;
2525
using FilterView = std::ranges::filter_view<View, AlwaysTrue>;
2626
using FilterSentinel = std::ranges::sentinel_t<FilterView>;
2727

2828
auto make_filter_view = [](auto begin, auto end, auto pred) {
29-
View view{Iterator(begin), Sentinel(Iterator(end))};
29+
View view{Iter(begin), Sent(Iter(end))};
3030
return FilterView(std::move(view), pred);
3131
};
3232

libcxx/test/std/ranges/range.adaptors/range.filter/types.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ struct AlwaysTrue {
3131
constexpr bool operator()(T const&) const { return true; }
3232
};
3333

34-
template <class Iterator, class Sentinel>
34+
template <class Iter, class Sent>
3535
struct minimal_view : std::ranges::view_base {
36-
constexpr explicit minimal_view(Iterator it, Sentinel sent)
36+
constexpr explicit minimal_view(Iter it, Sent sent)
3737
: it_(base(std::move(it)))
3838
, sent_(base(std::move(sent)))
3939
{ }
4040

4141
minimal_view(minimal_view&&) = default;
4242
minimal_view& operator=(minimal_view&&) = default;
4343

44-
constexpr Iterator begin() const { return Iterator(it_); }
45-
constexpr Sentinel end() const { return Sentinel(sent_); }
44+
constexpr Iter begin() const { return Iter(it_); }
45+
constexpr Sent end() const { return Sent(sent_); }
4646

4747
private:
48-
decltype(base(std::declval<Iterator>())) it_;
49-
decltype(base(std::declval<Sentinel>())) sent_;
48+
decltype(base(std::declval<Iter>())) it_;
49+
decltype(base(std::declval<Sent>())) sent_;
5050
};
5151

5252
template <bool IsNoexcept>

0 commit comments

Comments
 (0)