Skip to content

Commit a3b7579

Browse files
reuse common code
1 parent 6260bd1 commit a3b7579

File tree

4 files changed

+3
-139
lines changed

4 files changed

+3
-139
lines changed

libcxx/test/std/ranges/range.adaptors/range.concat/begin.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <cassert>
1515
#include "test_iterators.h"
1616
#include "types.h"
17+
#include "../range_adaptor_types.h"
1718

1819
template <class T>
1920
concept HasConstBegin = requires(const T& ct) { ct.begin(); };

libcxx/test/std/ranges/range.adaptors/range.concat/end.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "test_iterators.h"
1515
#include "types.h"
16+
#include "../range_adaptor_types.h"
1617

1718
constexpr bool test() {
1819
int buffer1[5] = {1, 2, 3, 4, 5};

libcxx/test/std/ranges/range.adaptors/range.concat/size.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "test_iterators.h"
1515
#include "types.h"
16+
#include "../range_adaptor_types.h"
1617

1718
int buffer[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
1819
struct View : std::ranges::view_base {

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

Lines changed: 0 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -42,143 +42,4 @@ struct minimal_view : std::ranges::view_base {
4242
decltype(base(std::declval<Sent>())) sent_;
4343
};
4444

45-
template <class T>
46-
struct BufferView : std::ranges::view_base {
47-
T* buffer_;
48-
std::size_t size_;
49-
50-
template <std::size_t N>
51-
constexpr BufferView(T (&b)[N]) : buffer_(b), size_(N) {}
52-
};
53-
54-
using IntBufferView = BufferView<int>;
55-
56-
template <bool Simple>
57-
struct Common : IntBufferView {
58-
using IntBufferView::IntBufferView;
59-
60-
constexpr int* begin()
61-
requires(!Simple)
62-
{
63-
return buffer_;
64-
}
65-
constexpr const int* begin() const { return buffer_; }
66-
constexpr int* end()
67-
requires(!Simple)
68-
{
69-
return buffer_ + size_;
70-
}
71-
constexpr const int* end() const { return buffer_ + size_; }
72-
};
73-
74-
using SimpleCommon = Common<true>;
75-
using NonSimpleCommon = Common<false>;
76-
77-
using SimpleCommonRandomAccessSized = SimpleCommon;
78-
using NonSimpleCommonRandomAccessSized = NonSimpleCommon;
79-
80-
template <bool Simple>
81-
struct NonCommon : IntBufferView {
82-
using IntBufferView::IntBufferView;
83-
constexpr int* begin()
84-
requires(!Simple)
85-
{
86-
return buffer_;
87-
}
88-
constexpr const int* begin() const { return buffer_; }
89-
constexpr sentinel_wrapper<int*> end()
90-
requires(!Simple)
91-
{
92-
return sentinel_wrapper<int*>(buffer_ + size_);
93-
}
94-
constexpr sentinel_wrapper<const int*> end() const { return sentinel_wrapper<const int*>(buffer_ + size_); }
95-
};
96-
97-
using SimpleNonCommon = NonCommon<true>;
98-
using NonSimpleNonCommon = NonCommon<false>;
99-
100-
template <bool Simple>
101-
struct NonCommonSized : IntBufferView {
102-
using IntBufferView::IntBufferView;
103-
constexpr int* begin()
104-
requires(!Simple)
105-
{
106-
return buffer_;
107-
}
108-
constexpr const int* begin() const { return buffer_; }
109-
constexpr sentinel_wrapper<int*> end()
110-
requires(!Simple)
111-
{
112-
return sentinel_wrapper<int*>(buffer_ + size_);
113-
}
114-
constexpr sentinel_wrapper<const int*> end() const { return sentinel_wrapper<const int*>(buffer_ + size_); }
115-
constexpr std::size_t size() const { return size_; }
116-
};
117-
118-
using SimpleNonCommonSized = NonCommonSized<true>;
119-
using SimpleNonCommonRandomAccessSized = SimpleNonCommonSized;
120-
using NonSimpleNonCommonSized = NonCommonSized<false>;
121-
using NonSimpleNonCommonRandomAccessSized = NonSimpleNonCommonSized;
122-
123-
template <bool Simple>
124-
struct NonCommonNonRandom : IntBufferView {
125-
using IntBufferView::IntBufferView;
126-
127-
using const_iterator = forward_iterator<const int*>;
128-
using iterator = forward_iterator<int*>;
129-
130-
constexpr iterator begin()
131-
requires(!Simple)
132-
{
133-
return iterator(buffer_);
134-
}
135-
constexpr const_iterator begin() const { return const_iterator(buffer_); }
136-
constexpr sentinel_wrapper<iterator> end()
137-
requires(!Simple)
138-
{
139-
return sentinel_wrapper<iterator>(iterator(buffer_ + size_));
140-
}
141-
constexpr sentinel_wrapper<const_iterator> end() const {
142-
return sentinel_wrapper<const_iterator>(const_iterator(buffer_ + size_));
143-
}
144-
};
145-
146-
using SimpleNonCommonNonRandom = NonCommonNonRandom<true>;
147-
using NonSimpleNonCommonNonRandom = NonCommonNonRandom<false>;
148-
149-
template <class Iter, class Sent = Iter, class NonConstIter = Iter, class NonConstSent = Sent>
150-
struct BasicView : IntBufferView {
151-
using IntBufferView::IntBufferView;
152-
153-
constexpr NonConstIter begin()
154-
requires(!std::is_same_v<Iter, NonConstIter>)
155-
{
156-
return NonConstIter(buffer_);
157-
}
158-
constexpr Iter begin() const { return Iter(buffer_); }
159-
160-
constexpr NonConstSent end()
161-
requires(!std::is_same_v<Sent, NonConstSent>)
162-
{
163-
if constexpr (std::is_same_v<NonConstIter, NonConstSent>) {
164-
return NonConstIter(buffer_ + size_);
165-
} else {
166-
return NonConstSent(NonConstIter(buffer_ + size_));
167-
}
168-
}
169-
170-
constexpr Sent end() const {
171-
if constexpr (std::is_same_v<Iter, Sent>) {
172-
return Iter(buffer_ + size_);
173-
} else {
174-
return Sent(Iter(buffer_ + size_));
175-
}
176-
}
177-
};
178-
179-
using NonSizedRandomAccessView =
180-
BasicView<random_access_iterator<int*>, sentinel_wrapper<random_access_iterator<int*>>>;
181-
182-
using InputCommonView = BasicView<common_input_iterator<int*>>;
183-
18445
#endif // TEST_STD_RANGES_RANGE_ADAPTORS_CONCAT_FILTER_TYPES_H

0 commit comments

Comments
 (0)