Skip to content

Commit bcdb11e

Browse files
committed
[libc++][NFC] Reindent take_view in accordance with the style guide.
1 parent cac4e2f commit bcdb11e

File tree

1 file changed

+108
-106
lines changed

1 file changed

+108
-106
lines changed

libcxx/include/__ranges/take_view.h

Lines changed: 108 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -37,141 +37,143 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3737
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
3838

3939
namespace ranges {
40-
template<view _View>
41-
class take_view : public view_interface<take_view<_View>> {
42-
_LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
43-
range_difference_t<_View> __count_ = 0;
44-
45-
template<bool> class __sentinel;
46-
47-
public:
48-
_LIBCPP_HIDE_FROM_ABI
49-
take_view() requires default_initializable<_View> = default;
50-
51-
_LIBCPP_HIDE_FROM_ABI
52-
constexpr take_view(_View __base, range_difference_t<_View> __count)
53-
: __base_(std::move(__base)), __count_(__count) {}
54-
55-
_LIBCPP_HIDE_FROM_ABI
56-
constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
57-
58-
_LIBCPP_HIDE_FROM_ABI
59-
constexpr _View base() && { return std::move(__base_); }
60-
61-
_LIBCPP_HIDE_FROM_ABI
62-
constexpr auto begin() requires (!__simple_view<_View>) {
63-
if constexpr (sized_range<_View>) {
64-
if constexpr (random_access_range<_View>) {
65-
return ranges::begin(__base_);
66-
} else {
67-
using _DifferenceT = range_difference_t<_View>;
68-
auto __size = size();
69-
return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
70-
}
40+
41+
template<view _View>
42+
class take_view : public view_interface<take_view<_View>> {
43+
_LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
44+
range_difference_t<_View> __count_ = 0;
45+
46+
template<bool> class __sentinel;
47+
48+
public:
49+
_LIBCPP_HIDE_FROM_ABI
50+
take_view() requires default_initializable<_View> = default;
51+
52+
_LIBCPP_HIDE_FROM_ABI
53+
constexpr take_view(_View __base, range_difference_t<_View> __count)
54+
: __base_(std::move(__base)), __count_(__count) {}
55+
56+
_LIBCPP_HIDE_FROM_ABI
57+
constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
58+
59+
_LIBCPP_HIDE_FROM_ABI
60+
constexpr _View base() && { return std::move(__base_); }
61+
62+
_LIBCPP_HIDE_FROM_ABI
63+
constexpr auto begin() requires (!__simple_view<_View>) {
64+
if constexpr (sized_range<_View>) {
65+
if constexpr (random_access_range<_View>) {
66+
return ranges::begin(__base_);
7167
} else {
72-
return counted_iterator(ranges::begin(__base_), __count_);
68+
using _DifferenceT = range_difference_t<_View>;
69+
auto __size = size();
70+
return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
7371
}
72+
} else {
73+
return counted_iterator(ranges::begin(__base_), __count_);
7474
}
75+
}
7576

76-
_LIBCPP_HIDE_FROM_ABI
77-
constexpr auto begin() const requires range<const _View> {
78-
if constexpr (sized_range<const _View>) {
79-
if constexpr (random_access_range<const _View>) {
80-
return ranges::begin(__base_);
81-
} else {
82-
using _DifferenceT = range_difference_t<const _View>;
83-
auto __size = size();
84-
return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
85-
}
77+
_LIBCPP_HIDE_FROM_ABI
78+
constexpr auto begin() const requires range<const _View> {
79+
if constexpr (sized_range<const _View>) {
80+
if constexpr (random_access_range<const _View>) {
81+
return ranges::begin(__base_);
8682
} else {
87-
return counted_iterator(ranges::begin(__base_), __count_);
83+
using _DifferenceT = range_difference_t<const _View>;
84+
auto __size = size();
85+
return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
8886
}
87+
} else {
88+
return counted_iterator(ranges::begin(__base_), __count_);
8989
}
90+
}
9091

91-
_LIBCPP_HIDE_FROM_ABI
92-
constexpr auto end() requires (!__simple_view<_View>) {
93-
if constexpr (sized_range<_View>) {
94-
if constexpr (random_access_range<_View>) {
95-
return ranges::begin(__base_) + size();
96-
} else {
97-
return default_sentinel;
98-
}
92+
_LIBCPP_HIDE_FROM_ABI
93+
constexpr auto end() requires (!__simple_view<_View>) {
94+
if constexpr (sized_range<_View>) {
95+
if constexpr (random_access_range<_View>) {
96+
return ranges::begin(__base_) + size();
9997
} else {
100-
return __sentinel<false>{ranges::end(__base_)};
98+
return default_sentinel;
10199
}
100+
} else {
101+
return __sentinel<false>{ranges::end(__base_)};
102102
}
103+
}
103104

104-
_LIBCPP_HIDE_FROM_ABI
105-
constexpr auto end() const requires range<const _View> {
106-
if constexpr (sized_range<const _View>) {
107-
if constexpr (random_access_range<const _View>) {
108-
return ranges::begin(__base_) + size();
109-
} else {
110-
return default_sentinel;
111-
}
105+
_LIBCPP_HIDE_FROM_ABI
106+
constexpr auto end() const requires range<const _View> {
107+
if constexpr (sized_range<const _View>) {
108+
if constexpr (random_access_range<const _View>) {
109+
return ranges::begin(__base_) + size();
112110
} else {
113-
return __sentinel<true>{ranges::end(__base_)};
111+
return default_sentinel;
114112
}
113+
} else {
114+
return __sentinel<true>{ranges::end(__base_)};
115115
}
116+
}
116117

117118

118-
_LIBCPP_HIDE_FROM_ABI
119-
constexpr auto size() requires sized_range<_View> {
120-
auto __n = ranges::size(__base_);
121-
return ranges::min(__n, static_cast<decltype(__n)>(__count_));
122-
}
119+
_LIBCPP_HIDE_FROM_ABI
120+
constexpr auto size() requires sized_range<_View> {
121+
auto __n = ranges::size(__base_);
122+
return ranges::min(__n, static_cast<decltype(__n)>(__count_));
123+
}
123124

124-
_LIBCPP_HIDE_FROM_ABI
125-
constexpr auto size() const requires sized_range<const _View> {
126-
auto __n = ranges::size(__base_);
127-
return ranges::min(__n, static_cast<decltype(__n)>(__count_));
128-
}
129-
};
125+
_LIBCPP_HIDE_FROM_ABI
126+
constexpr auto size() const requires sized_range<const _View> {
127+
auto __n = ranges::size(__base_);
128+
return ranges::min(__n, static_cast<decltype(__n)>(__count_));
129+
}
130+
};
130131

131-
template<view _View>
132-
template<bool _Const>
133-
class take_view<_View>::__sentinel {
134-
using _Base = __maybe_const<_Const, _View>;
135-
template<bool _OtherConst>
136-
using _Iter = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>;
137-
_LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>();
132+
template<view _View>
133+
template<bool _Const>
134+
class take_view<_View>::__sentinel {
135+
using _Base = __maybe_const<_Const, _View>;
136+
template<bool _OtherConst>
137+
using _Iter = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>;
138+
_LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>();
138139

139-
template<bool>
140-
friend class take_view<_View>::__sentinel;
140+
template<bool>
141+
friend class take_view<_View>::__sentinel;
141142

142143
public:
143-
_LIBCPP_HIDE_FROM_ABI
144-
__sentinel() = default;
144+
_LIBCPP_HIDE_FROM_ABI
145+
__sentinel() = default;
145146

146-
_LIBCPP_HIDE_FROM_ABI
147-
constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(std::move(__end)) {}
147+
_LIBCPP_HIDE_FROM_ABI
148+
constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(std::move(__end)) {}
148149

149-
_LIBCPP_HIDE_FROM_ABI
150-
constexpr __sentinel(__sentinel<!_Const> __s)
151-
requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
152-
: __end_(std::move(__s.__end_)) {}
150+
_LIBCPP_HIDE_FROM_ABI
151+
constexpr __sentinel(__sentinel<!_Const> __s)
152+
requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
153+
: __end_(std::move(__s.__end_)) {}
153154

154-
_LIBCPP_HIDE_FROM_ABI
155-
constexpr sentinel_t<_Base> base() const { return __end_; }
155+
_LIBCPP_HIDE_FROM_ABI
156+
constexpr sentinel_t<_Base> base() const { return __end_; }
156157

157-
_LIBCPP_HIDE_FROM_ABI
158-
friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {
159-
return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
160-
}
158+
_LIBCPP_HIDE_FROM_ABI
159+
friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {
160+
return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
161+
}
161162

162-
template<bool _OtherConst = !_Const>
163-
requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
164-
_LIBCPP_HIDE_FROM_ABI
165-
friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {
166-
return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
167-
}
168-
};
163+
template<bool _OtherConst = !_Const>
164+
requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
165+
_LIBCPP_HIDE_FROM_ABI
166+
friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {
167+
return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
168+
}
169+
};
170+
171+
template<class _Range>
172+
take_view(_Range&&, range_difference_t<_Range>) -> take_view<views::all_t<_Range>>;
169173

170-
template<class _Range>
171-
take_view(_Range&&, range_difference_t<_Range>) -> take_view<views::all_t<_Range>>;
174+
template<class _Tp>
175+
inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>;
172176

173-
template<class _Tp>
174-
inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>;
175177
} // namespace ranges
176178

177179
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)

0 commit comments

Comments
 (0)