1414#include " test_iterators.h"
1515
1616struct DefaultConstructibleView : std::ranges::view_base {
17- int * begin_ = nullptr ;
18- int * end_ = nullptr ;
17+ int * begin_ = nullptr ;
18+ int * end_ = nullptr ;
1919 explicit DefaultConstructibleView () = default;
20- constexpr int * begin () const { return begin_; }
20+ constexpr int * begin () const { return begin_; }
2121 constexpr auto end () const { return sentinel_wrapper<int *>(end_); }
2222};
2323static_assert (std::ranges::view<DefaultConstructibleView>);
@@ -26,21 +26,21 @@ static_assert(std::default_initializable<DefaultConstructibleView>);
2626struct MoveOnlyView : std::ranges::view_base {
2727 int * begin_;
2828 int * end_;
29- constexpr explicit MoveOnlyView (int * b, int * e) : begin_(b), end_(e) { }
30- constexpr MoveOnlyView (MoveOnlyView&&) = default;
29+ constexpr explicit MoveOnlyView (int * b, int * e) : begin_(b), end_(e) {}
30+ constexpr MoveOnlyView (MoveOnlyView&&) = default;
3131 constexpr MoveOnlyView& operator =(MoveOnlyView&&) = default ;
32- constexpr int * begin () const { return begin_; }
32+ constexpr int * begin () const { return begin_; }
3333 constexpr auto end () const { return sentinel_wrapper<int *>(end_); }
3434};
35- static_assert ( std::ranges::view<MoveOnlyView>);
36- static_assert ( std::ranges::contiguous_range<MoveOnlyView>);
35+ static_assert (std::ranges::view<MoveOnlyView>);
36+ static_assert (std::ranges::contiguous_range<MoveOnlyView>);
3737static_assert (!std::copyable<MoveOnlyView>);
3838
3939struct CopyableView : std::ranges::view_base {
4040 int * begin_;
4141 int * end_;
42- constexpr explicit CopyableView (int * b, int * e) : begin_(b), end_(e) { }
43- constexpr int * begin () const { return begin_; }
42+ constexpr explicit CopyableView (int * b, int * e) : begin_(b), end_(e) {}
43+ constexpr int * begin () const { return begin_; }
4444 constexpr auto end () const { return sentinel_wrapper<int *>(end_); }
4545};
4646static_assert (std::ranges::view<CopyableView>);
@@ -50,7 +50,7 @@ using ForwardIter = forward_iterator<int*>;
5050struct SizedForwardView : std::ranges::view_base {
5151 int * begin_;
5252 int * end_;
53- constexpr explicit SizedForwardView (int * b, int * e) : begin_(b), end_(e) { }
53+ constexpr explicit SizedForwardView (int * b, int * e) : begin_(b), end_(e) {}
5454 constexpr auto begin () const { return forward_iterator<int *>(begin_); }
5555 constexpr auto end () const { return sized_sentinel<forward_iterator<int *>>(forward_iterator<int *>(end_)); }
5656};
@@ -62,9 +62,11 @@ using RandomAccessIter = random_access_iterator<int*>;
6262struct SizedRandomAccessView : std::ranges::view_base {
6363 int * begin_;
6464 int * end_;
65- constexpr explicit SizedRandomAccessView (int * b, int * e) : begin_(b), end_(e) { }
65+ constexpr explicit SizedRandomAccessView (int * b, int * e) : begin_(b), end_(e) {}
6666 constexpr auto begin () const { return random_access_iterator<int *>(begin_); }
67- constexpr auto end () const { return sized_sentinel<random_access_iterator<int *>>(random_access_iterator<int *>(end_)); }
67+ constexpr auto end () const {
68+ return sized_sentinel<random_access_iterator<int *>>(random_access_iterator<int *>(end_));
69+ }
6870};
6971static_assert (std::ranges::view<SizedRandomAccessView>);
7072static_assert (std::ranges::random_access_range<SizedRandomAccessView>);
@@ -73,21 +75,21 @@ static_assert(std::ranges::sized_range<SizedRandomAccessView>);
7375struct CommonView : std::ranges::view_base {
7476 int * begin_;
7577 int * end_;
76- constexpr explicit CommonView (int * b, int * e) : begin_(b), end_(e) { }
77- constexpr int * begin () const { return begin_; }
78- constexpr int * end () const { return end_; }
78+ constexpr explicit CommonView (int * b, int * e) : begin_(b), end_(e) {}
79+ constexpr int * begin () const { return begin_; }
80+ constexpr int * end () const { return end_; }
7981};
8082static_assert (std::ranges::view<CommonView>);
8183static_assert (std::ranges::common_range<CommonView>);
8284
8385struct NonCommonView : std::ranges::view_base {
8486 int * begin_;
8587 int * end_;
86- constexpr explicit NonCommonView (int * b, int * e) : begin_(b), end_(e) { }
87- constexpr int * begin () const { return begin_; }
88+ constexpr explicit NonCommonView (int * b, int * e) : begin_(b), end_(e) {}
89+ constexpr int * begin () const { return begin_; }
8890 constexpr auto end () const { return sentinel_wrapper<int *>(end_); }
8991};
90- static_assert ( std::ranges::view<NonCommonView>);
92+ static_assert (std::ranges::view<NonCommonView>);
9193static_assert (!std::ranges::common_range<NonCommonView>);
9294
9395template <class T >
@@ -107,22 +109,30 @@ concept HasOnlyNonConstBegin = HasBegin<T> && !HasConstBegin<T>;
107109template <class T >
108110concept HasOnlyConstBegin = HasConstBegin<T> && !HasConstAndNonConstBegin<T>;
109111
110- template <bool Simple>
111- struct NonCommonBaseView : std::ranges::view_base {
112+ template <bool Simple>
113+ struct NonCommonBaseView : std::ranges::view_base {
112114 int * begin_;
113115 int * end_;
114- constexpr explicit NonCommonBaseView (int * b, int * e) : begin_(b), end_(e) { }
116+ constexpr explicit NonCommonBaseView (int * b, int * e) : begin_(b), end_(e) {}
115117 constexpr auto begin () const { return static_cast <const int *>(begin_); }
116118 constexpr auto end () const { return sentinel_wrapper<const int *>(end_); }
117- constexpr int *begin () requires (!Simple) { return begin_; }
118- constexpr auto end () requires (!Simple) { return sentinel_wrapper<int *>(end_); }
119+ constexpr int * begin ()
120+ requires(!Simple)
121+ {
122+ return begin_;
123+ }
124+ constexpr auto end ()
125+ requires(!Simple)
126+ {
127+ return sentinel_wrapper<int *>(end_);
128+ }
119129};
120130using NonSimpleNonCommonView = NonCommonBaseView<false >;
121131
122- static_assert (!HasOnlyNonConstBegin<std::ranges::common_view<const NonSimpleNonCommonView>>);
132+ static_assert (!HasOnlyNonConstBegin<std::ranges::common_view<NonSimpleNonCommonView>>);
123133static_assert (!HasOnlyConstBegin<std::ranges::common_view<NonSimpleNonCommonView>>);
124134static_assert (HasConstAndNonConstBegin<std::ranges::common_view<NonSimpleNonCommonView>>);
125- static_assert (HasConstBegin<std::ranges::common_view<const NonSimpleNonCommonView>>);
126- static_assert (HasOnlyConstBegin<std::ranges::common_view<const NonSimpleNonCommonView>>);
135+ static_assert (HasConstBegin<std::ranges::common_view<NonSimpleNonCommonView> const >);
136+ static_assert (HasOnlyConstBegin<std::ranges::common_view<NonSimpleNonCommonView> const >);
127137
128138#endif // TEST_STD_RANGES_RANGE_ADAPTORS_RANGE_COMMON_VIEW_TYPES_H
0 commit comments