12 #ifndef RAH_DONT_USE_STD 15 #pragma warning(push, 0) 17 #include <type_traits> 34 #include "rah_custom_std.hpp" 39 #define RAH_NAMESPACE rah 45 constexpr intptr_t
End = -1;
49 template<
class T,
size_t N> T*
begin(T(&array)[N]) {
return (T*)array; }
51 template<
class T,
size_t N> T*
end(T(&array)[N]) noexcept {
return array + N; }
54 template<
typename T> T&
fake() {
return *((RAH_STD::remove_reference_t<T>*)
nullptr); }
69 using range_iter_categ_t =
typename RAH_STD::iterator_traits<range_begin_type_t<R>>::iterator_category;
71 template<
typename R,
typename =
int>
72 struct is_range {
static constexpr
bool value =
false; };
75 struct is_range <R, decltype(
begin(
fake<R>()),
end(
fake<R>()), 0)> {
static constexpr
bool value =
true; };
85 I
begin()
const {
return begin_iter; }
86 I
begin() {
return begin_iter; }
87 I
end()
const {
return end_iter; }
88 I
end() {
return end_iter; }
94 return iterator_range<I>{b, e};
98 template<
typename I> I
begin(iterator_range<I>& r) {
return r.begin_iter; }
100 template<
typename I> I
end(iterator_range<I>& r) {
return r.end_iter; }
102 template<
typename I> I
begin(iterator_range<I>
const& r) {
return r.begin_iter; }
104 template<
typename I> I
end(iterator_range<I>
const& r) {
return r.end_iter; }
108 template<
typename Func>
114 template<
typename MakeRange>
117 return pipeable<MakeRange>{ make_range };
120 template<
typename R,
typename MakeRange>
121 auto operator | (R&& range, pipeable<MakeRange>
const& adapter) ->decltype(adapter.func(RAH_STD::forward<R>(range)))
123 return adapter.func(RAH_STD::forward<R>(range));
139 new(getPtr()) T(other.
get());
140 is_allocated_ =
true;
151 new(getPtr()) T(other.
get());
152 is_allocated_ =
true;
161 new(getPtr()) T(other.
get());
162 is_allocated_ =
true;
171 if (other.has_value())
175 new(getPtr()) T(RAH_STD::move(other.get()));
176 is_allocated_ =
true;
183 if (other.has_value())
185 new(getPtr()) T(RAH_STD::move(other.get()));
186 is_allocated_ =
true;
193 new(getPtr()) T(other);
194 is_allocated_ =
true;
198 new(getPtr()) T(other);
199 is_allocated_ =
true;
204 new(getPtr()) T(RAH_STD::move(other));
205 is_allocated_ =
true;
217 is_allocated_ =
false;
223 T
const&
get()
const {
assert(is_allocated_);
return *getPtr(); }
225 T& operator*() {
return get(); }
226 T
const& operator*()
const {
return get(); }
231 T* getPtr() {
return (T*)&value_; }
232 T
const* getPtr()
const {
return (T
const*)&value_; }
233 void destruct_value() { get().~T(); }
235 RAH_STD::aligned_storage_t<
sizeof(T), RAH_STD::alignment_of<T>::value> value_;
236 bool is_allocated_ =
false;
240 template<
typename I,
typename R,
typename C>
struct iterator_facade;
242 template<
typename I,
typename R>
243 struct iterator_facade<I, R,
RAH_STD::forward_iterator_tag>
245 template <
class Reference>
248 using type = RAH_NAMESPACE::details::optional<Reference>;
249 template<
typename Ref>
252 return RAH_STD::forward<Ref>(ref);
257 struct pointer_type<T&>
260 template<
typename Ref>
273 static_assert(not RAH_STD::is_reference<value_type>::value,
"value_type can't be a reference");
275 I&
self() {
return *static_cast<I*>(
this); }
276 I
const&
self()
const {
return *static_cast<I const*>(
this); }
286 static_assert(RAH_STD::is_same<decltype(
self().dereference()),
reference>::value,
"");
287 return self().dereference();
289 auto operator->()
const {
return pointer_type<R>::to_pointer(
self().dereference()); }
294 template<
typename I,
typename R>
295 struct iterator_facade<I, R,
RAH_STD::output_iterator_tag>
303 static_assert(not RAH_STD::is_reference<value_type>::value,
"value_type can't be a reference");
305 I&
self() {
return *static_cast<I*>(
this); }
306 I
const&
self()
const {
return *static_cast<I const*>(
this); }
309 auto& operator*()
const {
return *
this; }
316 self().put(RAH_STD::forward<V>(value));
322 template<
typename I,
typename R>
323 struct iterator_facade<I, R,
RAH_STD::bidirectional_iterator_tag> : iterator_facade<I, R, RAH_STD::forward_iterator_tag>
327 I&
self() {
return *static_cast<I*>(
this); }
328 I
const&
self()
const {
return *static_cast<I const*>(
this); }
337 template<
typename I,
typename R>
338 struct iterator_facade<I, R,
RAH_STD::random_access_iterator_tag> : iterator_facade<I, R, RAH_STD::bidirectional_iterator_tag>
342 I&
self() {
return *static_cast<I*>(
this); }
343 I
const&
self()
const {
return *static_cast<I const*>(
this); }
347 self().advance(increment);
354 iter.advance(increment);
360 self().advance(-increment);
367 iter.advance(-increment);
371 auto operator-(I other)
const {
return self().distance_to(other); }
372 bool operator<(I other)
const {
return self().distance_to(other) < 0; }
373 bool operator<=(I other)
const {
return self().distance_to(other) <= 0; }
374 bool operator>(I other)
const {
return self().distance_to(other) > 0; }
375 bool operator>=(I other)
const {
return self().distance_to(other) >= 0; }
376 auto operator[](intptr_t increment)
const {
return *(
self() + increment); }
383 struct back_insert_iterator : iterator_facade<back_insert_iterator<C>, range_ref_type_t<C>, RAH_STD::output_iterator_tag>
387 template<
typename V>
void put(V&& value)
const { container_->emplace_back(value); }
395 using Container = RAH_STD::remove_reference_t<C>;
396 auto begin = back_insert_iterator<Container>(container);
397 auto end = back_insert_iterator<Container>(container);
404 template<
typename A,
typename B>
bool operator()(A&& a, B&& b) {
return a < b; }
413 template<
typename R>
auto all(R&& range)
415 return iterator_range<range_begin_type_t<R>>{
begin(range),
end(range)};
426 struct take_iterator : iterator_facade<
428 decltype(*fake<I>()),
429 typename RAH_STD::iterator_traits<I>::iterator_category
433 size_t count_ = size_t();
435 take_iterator() =
default;
439 void advance(intptr_t off) { iter_ += off; count_ += off; }
446 template<
typename R>
auto take(R&& range,
size_t count)
448 using iterator = take_iterator<range_begin_type_t<R>>;
449 iterator iter1(
begin(range), 0);
465 typename RAH_STD::iterator_traits<I>::iterator_category
475 : subRangeBegin_(subRangeBegin)
476 , subRangeLast_(subRangeLast)
481 void advance(intptr_t off) { subRangeBegin_ += off; subRangeLast_ += off; }
486 I endIter = subRangeLast_;
493 template<
typename R>
auto sliding(R&& range,
size_t n)
495 size_t const closedSubRangeSize = n - 1;
496 auto const rangeEnd =
end(range);
498 auto subRangeBegin =
begin(range);
499 auto subRangeLast = subRangeBegin;
500 for (
size_t i = 0; i != closedSubRangeSize; ++i)
502 if (subRangeLast == rangeEnd)
507 auto endSubRangeBegin = rangeEnd;
508 RAH_STD::advance(endSubRangeBegin, -intptr_t(n - 1));
510 iterator iter1(subRangeBegin, subRangeLast);
511 iterator iter2(endSubRangeBegin, rangeEnd);
524 auto iter1 =
begin(range);
525 auto iter2 =
end(range);
526 RAH_STD::advance(iter1,
count);
539 auto iter1 =
begin(range);
540 auto iter2 =
end(range);
541 for(
size_t i = 0; i <
count; ++i)
560 decltype(*fake<I>()),
561 typename RAH_STD::iterator_traits<I>::iterator_category
565 size_t count_ = size_t();
567 counted_iterator() =
default;
571 void advance(intptr_t off) { iter_ += off; count_ += off; }
578 template<
typename I>
auto counted(I&& it,
size_t n, decltype(++it, 0) = 0)
580 using iterator = counted_iterator<RAH_STD::remove_reference_t<I>>;
581 iterator iter1(it, 0);
582 iterator iter2(it, n);
588 template<
typename R>
auto counted(R&& range,
size_t n, decltype(
begin(range), 0) = 0)
590 return take(range, n);
602 struct unbounded_iterator : iterator_facade<
603 unbounded_iterator<I>,
604 decltype(*fake<I>()),
605 typename RAH_STD::iterator_traits<I>::iterator_category
611 unbounded_iterator() =
default;
625 return RAH_STD::numeric_limits<intptr_t>::min();
630 return RAH_STD::numeric_limits<intptr_t>::max();
632 return iter_ - r.iter_;
641 (r.end_?
false: r.iter_ == iter_);
645 template<
typename I>
auto unbounded(I&& it)
647 using iterator = unbounded_iterator<RAH_STD::remove_reference_t<I>>;
648 iterator iter1(it,
false);
649 iterator iter2(it,
true);
656 template<
typename T =
size_t>
657 struct ints_iterator : iterator_facade<ints_iterator<T>, T, RAH_STD::random_access_iterator_tag>
661 ints_iterator() =
default;
665 void advance(intptr_t value) { val_ += T(value); }
672 template<
typename T =
size_t>
auto ints(T b = 0, T e = RAH_STD::numeric_limits<T>::max())
677 template<
typename T =
size_t>
auto closed_ints(T b = 0, T e = RAH_STD::numeric_limits<T>::max() - 1)
685 template<
typename T =
size_t>
686 struct iota_iterator :
iterator_facade<iota_iterator<T>, T, RAH_STD::random_access_iterator_tag>
691 iota_iterator() =
default;
695 void advance(intptr_t value) { val_ += T(step_ * value); }
702 template<
typename T =
size_t>
auto iota(T b, T e, T step = 1)
706 diff = ((diff + (step - 1)) / step) * step;
714 struct repeat_iterator : iterator_facade<repeat_iterator<V>, V const&, RAH_STD::forward_iterator_tag>
718 repeat_iterator() =
default;
729 template<
typename V>
auto repeat(V&& value)
737 struct join_iterator : iterator_facade<join_iterator<R>, range_ref_type_t<range_ref_type_t<R>>, RAH_STD::forward_iterator_tag>
752 : range_(
RAH_STD::forward<U>(range))
753 , rangeIter_(rangeIter)
754 , subRange_(
SubRange{ subRangeIter, subRangeEnd })
756 if (rangeIter_ ==
end(range_))
763 : range_(
RAH_STD::forward<U>(range))
764 , rangeIter_(rangeIter)
770 while (subRange_->subRangeIter == subRange_->subRangeEnd)
773 if (rangeIter_ ==
end(range_))
777 auto&& subRange = *rangeIter_;
778 subRange_->subRangeIter =
begin(subRange);
779 subRange_->subRangeEnd =
end(subRange);
786 ++subRange_->subRangeIter;
789 auto dereference() const ->decltype(*subRange_->subRangeIter) {
return *subRange_->subRangeIter; }
792 if (rangeIter_ ==
end(range_))
793 return rangeIter_ == other.rangeIter_;
795 return rangeIter_ == other.rangeIter_ && subRange_->subRangeIter == other.subRange_->subRangeIter;
799 template<
typename R>
auto join(R&& range_of_ranges)
802 using join_iterator_type = join_iterator<decltype(rangeRef)>;
803 auto rangeBegin =
begin(rangeRef);
804 auto rangeEnd =
end(rangeRef);
807 join_iterator_type b(rangeRef, rangeBegin);
808 join_iterator_type e(rangeRef, rangeEnd);
813 auto&& firstSubRange = *rangeBegin;
814 join_iterator_type b(rangeRef, rangeBegin,
begin(firstSubRange),
end(firstSubRange));
815 join_iterator_type e(rangeRef, rangeEnd);
828 struct cycle_iterator : iterator_facade<cycle_iterator<R>, range_ref_type_t<R>, RAH_STD::forward_iterator_tag>
838 : range_(
RAH_STD::forward<U>(range))
839 , beginIter_(
begin(range_))
840 , endIter_(
end(range_))
848 while (iter_ == endIter_)
849 iter_ =
begin(range_);
858 template<
typename R>
auto cycle(R&& range)
861 using iterator_type = cycle_iterator<RAH_STD::remove_reference_t<decltype(rangeRef)>>;
863 iterator_type b(rangeRef,
begin(rangeRef));
864 iterator_type e(rangeRef,
begin(rangeRef));
877 struct generate_iterator : iterator_facade<generate_iterator<F>, decltype(fake<F>()()), RAH_STD::forward_iterator_tag>
879 mutable RAH_NAMESPACE::details::optional<F>
func_;
888 template<
typename F>
auto generate(F&& func)
890 using Functor = RAH_STD::remove_cv_t<RAH_STD::remove_reference_t<F>>;
901 template<
typename R,
typename F>
902 struct transform_iterator : iterator_facade<
903 transform_iterator<R, F>,
904 decltype(fake<F>()(fake<range_ref_type_t<R>>())),
905 range_iter_categ_t<R>
908 range_begin_type_t<R> iter_;
909 RAH_NAMESPACE::details::optional<F>
func_;
924 auto dereference() const -> decltype((*func_)(*iter_)) {
return (*func_)(*iter_); }
928 template<
typename R,
typename F>
auto transform(R&& range, F&& func)
930 using Functor = RAH_STD::remove_cv_t<RAH_STD::remove_reference_t<F>>;
931 using iterator = transform_iterator<RAH_STD::remove_reference_t<R>, Functor>;
932 auto iter1 =
begin(range);
933 auto iter2 =
end(range);
937 template<
typename F>
auto transform(F&& func)
944 template<
typename InputIt1,
typename InputIt2>
946 set_difference_iterator<InputIt1, InputIt2>,
947 typename RAH_STD::iterator_traits<InputIt1>::reference,
948 RAH_STD::forward_iterator_tag
957 : first1_(first1) , last1_(last1) , first2_(first2), last2_(last2)
964 while (first2_ != last2_ and first1_ != last1_)
966 if (*first1_ < *first2_)
968 else if (*first1_ == *first2_)
983 auto dereference() const -> decltype(*first1_) {
return *first1_; }
994 { Iterator(
end(range1),
end(range1),
end(range2),
end(range2)) },
1005 template<
typename R,
typename F>
auto for_each(R&& range, F&& func)
1010 template<
typename F>
1018 template<
typename R>
auto slice(R&& range, intptr_t begin_idx, intptr_t end_idx)
1020 static_assert(not RAH_STD::is_same<range_iter_categ_t<R>, RAH_STD::forward_iterator_tag>::value,
1021 "Can't use slice on non-bidirectional iterators. Try to use view::drop and view::take");
1022 auto findIter = [](
auto b,
auto e, intptr_t idx)
1027 RAH_STD::advance(e, idx);
1032 RAH_STD::advance(b, idx);
1036 auto b_in =
begin(range);
1037 auto e_in =
end(range);
1038 auto b_out = findIter(b_in, e_in, begin_idx);
1039 auto e_out = findIter(b_in, e_in, end_idx);
1040 return iterator_range<decltype(b_out)>{ {b_out}, { e_out } };
1050 template<
typename R>
1051 struct stride_iterator : iterator_facade<stride_iterator<R>, range_ref_type_t<R>, range_iter_categ_t<R>>
1053 range_begin_type_t<R> iter_;
1054 range_end_type_t<R> end_;
1058 : iter_(iter), end_(
end), step_(step) {}
1062 for (
size_t i = 0; i < step_ && iter_ != end_; ++i)
1068 for (
size_t i = 0; i < step_; ++i)
1072 void advance(intptr_t value) { iter_ += step_ * value; }
1079 template<
typename R>
auto stride(R&& range,
size_t step)
1081 auto iter =
begin(range);
1082 auto endIter =
end(range);
1084 { iter, endIter, step}, { endIter, endIter, step }};
1087 inline auto stride(
size_t step)
1094 template<
typename R>
auto retro(R&& range)
1097 RAH_STD::make_reverse_iterator(
end(range)), RAH_STD::make_reverse_iterator(
begin(range)));
1107 template<
typename V>
1117 template <
typename Tuple,
typename F,
size_t ...Indices>
1118 void for_each_impl(Tuple&& tuple, F&& f, RAH_STD::index_sequence<Indices...>)
1120 using swallow =
int[];
1123 (f(RAH_STD::get<Indices>(RAH_STD::forward<Tuple>(tuple))), void(),
int{})...
1127 template <
typename Tuple,
typename F>
1128 void for_each(Tuple&& tuple, F&& f)
1130 constexpr
size_t N = RAH_STD::tuple_size<RAH_STD::remove_reference_t<Tuple>>::value;
1131 for_each_impl(RAH_STD::forward<Tuple>(tuple), RAH_STD::forward<F>(f),
1132 RAH_STD::make_index_sequence<N>{});
1135 template <
class F,
typename... Args,
size_t... Is>
1136 auto transform_each_impl(
const RAH_STD::tuple<Args...>& t, F&& f, RAH_STD::index_sequence<Is...>) {
1137 return RAH_STD::make_tuple(
1138 f(RAH_STD::get<Is>(t))...
1142 template <
class F,
typename... Args>
1143 auto transform_each(
const RAH_STD::tuple<Args...>& t, F&& f) {
1144 return transform_each_impl(
1145 t, RAH_STD::forward<F>(f), RAH_STD::make_index_sequence<
sizeof...(Args)>{});
1148 template <
typename... Args,
size_t... Is>
1149 auto deref_impl(
const RAH_STD::tuple<Args...>& t, RAH_STD::index_sequence<Is...>) {
1150 return RAH_STD::tuple<typename RAH_STD::iterator_traits<Args>::reference...>(
1151 (*RAH_STD::get<Is>(t))...
1155 template <
typename... Args>
1156 auto deref(
const RAH_STD::tuple<Args...>& t) {
1157 return deref_impl(t, RAH_STD::make_index_sequence<
sizeof...(Args)>{});
1160 template <
size_t Index>
1163 template <
typename... Args>
1164 bool operator()(RAH_STD::tuple<Args...>
const& a, RAH_STD::tuple<Args...>
const& b)
const 1166 return (RAH_STD::get<Index - 1>(a) == RAH_STD::get<Index - 1>(b)) || Equal<Index - 1>{}(a, b);
1173 template <
typename... Args>
1174 bool operator()(RAH_STD::tuple<Args...>
const&, RAH_STD::tuple<Args...>
const&)
const 1180 template <
typename... Args>
1181 auto equal(RAH_STD::tuple<Args...>
const& a, RAH_STD::tuple<Args...>
const& b)
1183 return Equal<
sizeof...(Args)>{}(a, b);
1189 template<
typename IterTuple>
1190 struct zip_iterator : iterator_facade<
1191 zip_iterator<IterTuple>,
1192 decltype(details::deref(fake<IterTuple>())),
1193 RAH_STD::bidirectional_iterator_tag
1197 zip_iterator() =
default;
1207 template<
typename ...R>
auto zip(R&&... _ranges)
1209 auto iterTup = RAH_STD::make_tuple(
begin(RAH_STD::forward<R>(_ranges))...);
1210 auto endTup = RAH_STD::make_tuple(
end(RAH_STD::forward<R>(_ranges))...);
1211 return iterator_range<zip_iterator<decltype(iterTup)>>{ { iterTup }, { endTup }};
1216 template<
typename R>
1217 struct chunk_iterator : iterator_facade<chunk_iterator<R>, iterator_range<range_begin_type_t<R>>, RAH_STD::forward_iterator_tag>
1219 range_begin_type_t<R> iter_;
1220 range_begin_type_t<R> iter2_;
1221 range_end_type_t<R> end_;
1229 : iter_(iter), iter2_(iter2), end_(
end), step_(step)
1236 for (
size_t i = 0; i != step_ and iter2_ != end_; ++i)
1244 template<
typename R>
auto chunk(R&& range,
size_t step)
1246 auto iter =
begin(range);
1247 auto endIter =
end(range);
1248 using iterator = chunk_iterator<RAH_STD::remove_reference_t<R>>;
1249 iterator
begin = { iter, iter, endIter, step };
1251 return iterator_range<iterator>{ {
begin }, { endIter, endIter, endIter, step }};
1254 inline auto chunk(
size_t step)
1261 template<
typename R,
typename F>
1262 struct filter_iterator : iterator_facade<filter_iterator<R, F>, range_ref_type_t<R>, RAH_STD::bidirectional_iterator_tag>
1268 RAH_NAMESPACE::details::optional<F>
func_;
1275 static auto get(I
const& iter) {
return iter.operator->(); }
1279 static auto get(V* ptr) {
return ptr; }
1287 : begin_(
begin), iter_(iter), end_(
end), func_(func)
1312 }
while (not (*func_)(*iter_) && iter_ != begin_);
1315 auto dereference() const -> decltype(*iter_) {
return *value_pointer_; }
1319 template<
typename R,
typename F>
auto filter(R&& range, F&& func)
1321 auto iter =
begin(range);
1322 auto endIter =
end(range);
1323 using Predicate = RAH_STD::remove_cv_t<RAH_STD::remove_reference_t<F>>;
1325 { iter, iter, endIter, func },
1326 { iter, endIter, endIter, func }
1330 template<
typename F>
auto filter(F&& func)
1337 template<
typename IterPair,
typename V>
1338 struct concat_iterator : iterator_facade<concat_iterator<IterPair, V>, V, RAH_STD::forward_iterator_tag>
1342 size_t range_index_;
1345 : iter_(iter), end_(
end), range_index_(range_index)
1351 if (range_index_ == 0)
1353 auto& i = RAH_STD::get<0>(iter_);
1355 if (i == RAH_STD::get<0>(end_))
1359 ++RAH_STD::get<1>(iter_);
1364 if (range_index_ == 0)
1365 return *RAH_STD::get<0>(iter_);
1367 return *RAH_STD::get<1>(iter_);
1372 if (range_index_ != other.range_index_)
1374 if (range_index_ == 0)
1375 return RAH_STD::get<0>(iter_) == RAH_STD::get<0>(other.iter_);
1377 return RAH_STD::get<1>(iter_) == RAH_STD::get<1>(other.iter_);
1382 template<
typename R1>
auto concat(R1&& range1)
1384 return RAH_STD::forward<R1>(range1);
1387 template<
typename R1,
typename R2>
auto concat(R1&& range1, R2&& range2)
1389 auto begin_range1 = RAH_STD::make_pair(
begin(range1),
begin(range2));
1390 auto begin_range2 = RAH_STD::make_pair(
end(range1),
end(range2));
1391 auto end_range1 = RAH_STD::make_pair(
end(range1),
end(range2));
1392 auto end_range2 = RAH_STD::make_pair(
end(range1),
end(range2));
1393 return iterator_range<
1395 RAH_STD::pair<range_begin_type_t<R1>, range_begin_type_t<R2>>,
1396 range_ref_type_t<R1>>>
1398 { begin_range1, begin_range2, 0 },
1399 { end_range1, end_range2, 1 },
1404 template<
typename R1,
typename R2,
typename ...Ranges>
1405 auto concat(R1&& range1, R2&& range2, Ranges&&... ranges)
1407 return concat(
concat(RAH_STD::forward<R1>(range1), RAH_STD::forward<R2>(range2)), ranges...);
1412 template<
typename R>
auto enumerate(R&& range)
1414 size_t const dist = RAH_STD::distance(
begin(RAH_STD::forward<R>(range)),
end(RAH_STD::forward<R>(range)));
1415 return zip(
iota(
size_t(0), dist), RAH_STD::forward<R>(range));
1425 template<
typename R>
auto map_value(R&& range)
1427 return transform(RAH_STD::forward<R>(range), [](
auto&& nvp) -> decltype(RAH_STD::get<1>(RAH_STD::forward<decltype(nvp)>(nvp)))
1429 return RAH_STD::get<1>(RAH_STD::forward<decltype(nvp)>(nvp));
1440 template<
typename R>
auto map_key(R&& range)
1442 return RAH_NAMESPACE::view::transform(RAH_STD::forward<R>(range), [](
auto&& nvp) -> decltype(RAH_STD::get<0>(RAH_STD::forward<decltype(nvp)>(nvp)))
1444 return RAH_STD::get<0>(RAH_STD::forward<decltype(nvp)>(nvp));
1461 template<typename R, typename P = is_lesser, typename = RAH_STD::enable_if_t<is_range<R>::value>>
1462 auto sort(R&& range, P&& pred = {})
1464 using value_type = range_value_type_t<R>;
1465 using Container =
typename RAH_STD::vector<value_type>;
1467 result.reserve(RAH_STD::distance(
begin(range),
end(range)));
1480 template<typename P = is_lesser, typename = RAH_STD::enable_if_t<not is_range<P>::value>>
1481 auto sort(P&& pred = {})
1483 return make_pipeable([=](
auto&& range) {
return view::sort(RAH_STD::forward<decltype(range)>(range), pred); });
1493 template<
typename R>
bool empty(R&& range)
1512 template<
typename R,
typename V>
1513 auto equal_range(R&& range, V&& value, RAH_STD::enable_if_t<is_range<R>::value,
int> = 0)
1532 template<
typename R,
typename V,
typename P>
1544 template<
typename V,
typename P>
1545 auto equal_range(V&& value, P&& pred, RAH_STD::enable_if_t<!is_range<V>::value,
int> = 0)
1547 return make_pipeable([=](
auto&& range) {
return equal_range(RAH_STD::forward<decltype(range)>(range), value, pred); });
1555 template<
typename R,
typename V>
auto binary_search(R&& range, V&& value)
1574 template<
typename RI,
typename RO,
typename F>
1575 auto transform(RI&& rangeIn, RO&& rangeOut, F&& unary_op)
1583 template<
typename RI1,
typename RI2,
typename RO,
typename F>
1584 auto transform(RI1&& rangeIn1, RI2&& rangeIn2, RO&& rangeOut, F&& binary_op)
1590 RAH_STD::forward<F>(binary_op));
1598 template<
typename R,
typename I,
typename F>
auto reduce(R&& range, I&& init, F&& reducer)
1600 return RAH_STD::accumulate(
begin(range),
end(range), RAH_STD::forward<I>(init), RAH_STD::forward<F>(reducer));
1607 template<
typename I,
typename F>
1608 auto reduce(I&& init, F&& reducer)
1618 template<
typename R,
typename F>
bool any_of(R&& range, F&& pred)
1627 template<
typename P>
auto any_of(P&& pred)
1637 template<
typename R,
typename P>
bool all_of(R&& range, P&& pred)
1646 template<
typename P>
auto all_of(P&& pred)
1656 template<
typename R,
typename P>
bool none_of(R&& range, P&& pred)
1665 template<
typename P>
auto none_of(P&& pred)
1675 template<
typename R,
typename V>
auto count(R&& range, V&& value)
1684 template<
typename V>
auto count(V&& value)
1693 template<
typename R,
typename P>
auto count_if(R&& range, P&& pred)
1701 template<
typename P>
auto count_if(P&& pred)
1711 template<
typename R,
typename F>
auto for_each(R&& range, F&& func)
1720 template<
typename F>
auto for_each(F&& func)
1730 template<
typename C,
typename R>
auto to_container(R&& range)
1732 return C(
begin(range),
end(range));
1741 return make_pipeable([=](
auto&& range) {
return to_container<C>(range); });
1749 template<
typename R1,
typename R2>
auto mismatch(R1&& range1, R2&& range2)
1759 template<
typename R,
typename V>
auto find(R&& range, V&& value)
1768 template<
typename V>
auto find(V&& value)
1776 template<
typename R,
typename P>
auto find_if(R&& range, P&& pred)
1785 template<
typename P>
auto find_if(P&& pred)
1793 template<
typename R,
typename P>
auto find_if_not(R&& range, P&& pred)
1812 template<typename R, RAH_STD::enable_if_t<is_range<R>::value,
int> = 0>
1830 template<
typename R,
typename P>
auto max_element(R&& range, P&& pred)
1839 template<typename P, RAH_STD::enable_if_t<!is_range<P>::value,
int> = 0>
1850 template<typename R, RAH_STD::enable_if_t<is_range<R>::value,
int> = 0>
1868 template<
typename R,
typename P>
auto min_element(R&& range, P&& pred)
1877 template<typename P, RAH_STD::enable_if_t<!is_range<P>::value,
int> = 0>
1889 template<
typename R1,
typename R2>
auto copy(R1&& in, R2&& out)
1899 template<
typename R2>
auto copy(R2&& out)
1910 template<
typename R1,
typename V>
auto fill(R1&& in, V&& value)
1919 template<
typename V>
auto fill(V&& value)
1929 template<
typename R1,
typename R2>
auto back_insert(R1&& in, R2&& out)
1949 template<
typename R1,
typename R2,
typename P>
auto copy_if(R1&& in, R2&& out, P&& pred)
1959 template<
typename R2,
typename P>
auto copy_if(R2&& out, P&& pred)
1970 template<
typename R>
auto size(R&& range)
1972 return RAH_STD::distance(
begin(range),
end(range));
1989 template<
typename R1,
typename R2>
auto equal(R1&& range1, R2&& range2)
1991 #ifdef EASTL_VERSION 1992 return RAH_STD::identical(
begin(range1),
end(range1),
begin(range2),
end(range2));
2002 template<
typename R1>
auto equal(R1&& range2)
2005 return make_pipeable([=](
auto&& range1) {
return equal(RAH_STD::forward<decltype(range1)>(range1), all_range2); });
2010 template<
typename S>
2011 struct stream_inserter_iterator : iterator_facade<stream_inserter_iterator<S>, typename S::char_type, RAH_STD::output_iterator_tag>
2015 template<
typename V>
void put(V&& value)
const { (*stream_) << value; }
2023 using Stream = RAH_STD::remove_reference_t<S>;
2024 auto begin = stream_inserter_iterator<Stream>(stream);
2025 auto end = stream_inserter_iterator<Stream>(stream);
2035 template<
typename R,
typename P>
auto remove_if(R&& range, P&& pred)
2045 template<
typename P>
auto remove_if(P&& pred)
2056 template<
typename R,
typename V>
auto remove(R&& range, V&& value)
2068 return make_pipeable([=](
auto&& range) {
return remove(RAH_STD::forward<decltype(range)>(range), value); });
2079 template<
typename R,
typename P>
auto partition(R&& range, P&& pred)
2088 template<
typename P>
auto partition(P&& pred)
2101 template<
typename R,
typename P>
auto stable_partition(R&& range, P&& pred)
2121 template<
typename C,
typename R>
auto erase(C&& container, R&& subrange)
2123 container.erase(
begin(subrange),
end(subrange));
2132 template<
typename R>
auto erase(R&& range)
2144 template<typename R, typename P = is_lesser, typename = RAH_STD::enable_if_t<is_range<R>::value>>
2145 void sort(R& range, P&& pred = {})
2155 template<typename P = is_lesser, typename = RAH_STD::enable_if_t<not is_range<P>::value>>
2156 auto sort(P&& pred = {})
2167 template<typename R, typename P = is_lesser, typename = RAH_STD::enable_if_t<is_range<R>::value>>
2178 template<typename P = is_lesser, typename = RAH_STD::enable_if_t<not is_range<P>::value>>
2189 template<
typename R,
typename URBG>
2190 void shuffle(R& range, URBG&& g)
2199 template<
typename URBG>
2210 template<
typename A,
typename B>
bool operator()(A&& a, B&& b) {
return a == b; }
2218 template<typename R, typename P = is_equal, typename = RAH_STD::enable_if_t<is_range<R>::value>>
2219 auto unique(R&& range, P&& pred = {})
2230 template<typename P = is_equal, typename = RAH_STD::enable_if_t<not is_range<P>::value>>
2231 auto unique(P&& pred = {})
2233 return make_pipeable([=](
auto&& range) {
return unique(RAH_STD::forward<decltype(range)>(range), pred); });
2242 template<
typename IN1,
typename IN2,
typename OUT_>
2257 template<
typename IN1,
typename IN2,
typename OUT_>
2276 template<typename C, typename P = is_equal, typename = RAH_STD::enable_if_t<is_range<C>::value>>
2277 auto&&
unique(C&& container, P&& pred = {})
2280 return RAH_STD::forward<C>(container);
2289 template<typename P = is_equal, typename = RAH_STD::enable_if_t<not is_range<P>::value>>
2290 auto unique(P&& pred = {})
2301 template<
typename C,
typename P>
auto&&
remove_if(C&& container, P&& pred)
2304 return RAH_STD::forward<C>(container);
2312 template<
typename P>
auto remove_if(P&& pred)
2314 return make_pipeable([=](
auto&& range) ->
auto&& {
return remove_if(RAH_STD::forward<decltype(range)>(range), pred); });
2323 template<
typename C,
typename V>
auto&&
remove(C&& container, V&& value)
2326 return RAH_STD::forward<C>(container);
2336 return make_pipeable([=](
auto&& range) ->
auto&& {
return remove(RAH_STD::forward<decltype(range)>(range), value); });
2346 template<typename C, typename P = is_lesser, typename = RAH_STD::enable_if_t<is_range<C>::value>>
2347 auto&&
sort(C&& container, P&& pred = {})
2350 return RAH_STD::forward<C>(container);
2359 template<typename P = is_lesser, typename = RAH_STD::enable_if_t<not is_range<P>::value>>
2360 auto sort(P&& pred = {})
2362 return make_pipeable([=](
auto&& range) ->
auto&& {
return action::sort(RAH_STD::forward<decltype(range)>(range), pred); });
2371 template<
typename C,
typename URBG>
2372 auto&&
shuffle(C&& container, URBG&& g)
2374 URBG gen = RAH_STD::forward<URBG>(g);
2376 return RAH_STD::forward<C>(container);
2384 template<
typename URBG>
2395 template<
typename R1,
typename V>
auto fill(R1&& in, V&& value)
2398 return RAH_STD::forward<R1>(in);
2405 template<
typename V>
auto fill(V&& value)
auto sliding(size_t n)
Given a range and a count n, place a window over the first n elements of the underlying range.
Definition: rah.hpp:515
void decrement()
Definition: rah.hpp:666
std ::remove_reference_t< range_ref_type_t< T > > range_value_type_t
Definition: rah - Copie.hpp:66
Definition: rah - Copie.hpp:555
auto & operator++()
Definition: rah.hpp:308
void decrement()
Definition: rah.hpp:696
auto distance_to(iota_iterator other) const
Definition: rah.hpp:697
auto dereference() const
Definition: rah.hpp:884
Definition: rah - Copie.hpp:80
auto generate_n(size_t count, F &&func)
Definition: rah - Copie.hpp:785
auto distance_to(zip_iterator other) const
Definition: rah.hpp:1203
counted_iterator(I iter, size_t count)
Definition: rah.hpp:568
auto distance_to(counted_iterator r) const
Definition: rah.hpp:573
auto dereference() const -> decltype(*iter_)
Definition: rah.hpp:636
Definition: rah - Copie.hpp:500
void stable_sort(R &range, P &&pred={})
Sorts the elements in the range in ascending order.
Definition: rah - Copie.hpp:1891
auto map_key(R &&range)
Given a range of std::pair-std::tuple, create a view consisting of just the second element of the pai...
Definition: rah - Copie.hpp:1260
void advance(intptr_t val)
Definition: rah.hpp:1200
concat_iterator(IterPair const &iter, IterPair const &end, size_t range_index)
Definition: rah.hpp:1344
auto binary_search(R &&range, V &&value)
Checks if an element equivalent to value appears within the range.
Definition: rah - Copie.hpp:1375
auto max_element(P &&pred)
Finds the greatest element in the range.
Definition: rah.hpp:1840
void set_difference(IN1 &&in1, IN2 &&in2, OUT_ &&out)
Copies the elements from the sorted range in1 which are not found in the sorted range in2 to the rang...
Definition: rah.hpp:2243
rah ::details::optional< SubRange > subRange_
Definition: rah.hpp:748
bool operator()(A &&a, B &&b)
Definition: rah.hpp:404
auto generate(F &&func)
Create an infinite range, repetitively calling func.
Definition: rah - Copie.hpp:779
static type to_pointer(Ref &&ref)
Definition: rah.hpp:250
auto stable_partition(R &&range, P &&pred)
Reorders the elements in the range in such a way that all elements for which the predicate pred retur...
Definition: rah - Copie.hpp:1824
auto operator+(intptr_t increment)
Definition: rah.hpp:351
bool has_value() const
Definition: rah.hpp:210
auto dereference() const -> decltype(*subRange_->subRangeIter)
Definition: rah.hpp:789
ints_iterator(T val)
Definition: rah.hpp:662
R reference
Definition: rah - Copie.hpp:154
decltype(end(fake< T >())) range_end_type_t
Definition: rah - Copie.hpp:60
bool equal(chunk_iterator other) const
Definition: rah.hpp:1241
bool equal(filter_iterator other) const
Definition: rah.hpp:1316
auto fill(R1 &&in, V &&value)
Assigns the given value to the elements in the range [first, last)
Definition: rah - Copie.hpp:1654
T const * operator->() const
Definition: rah.hpp:228
auto drop_exactly(size_t count)
Given a source range and an integral count, return a range consisting of all but the first count elem...
Definition: rah.hpp:530
auto transform(R &&range, F &&func)
Create a view applying a transformation to each element of the input range.
Definition: rah - Copie.hpp:819
InputIt1 last1_
Definition: rah.hpp:952
auto closed_ints(T b=0, T e=std ::numeric_limits< T >::max() - 1)
Generate a range of monotonically increasing ints.
Definition: rah.hpp:677
void increment()
Definition: rah.hpp:722
auto dereference() const -> decltype(*iter_)
Definition: rah.hpp:442
auto dereference() const -> decltype(*iter_)
Definition: rah.hpp:851
auto equal_range(R &&range, V &&value, std ::enable_if_t< is_range< R >::value, int >=0)
Returns a range containing all elements equivalent to value in the range.
Definition: rah - Copie.hpp:1333
auto chunk(R &&range, size_t step)
Create a view where each element is a range of N elements of the input range.
Definition: rah - Copie.hpp:1074
void decrement()
Definition: rah.hpp:617
void advance(intptr_t value)
Definition: rah.hpp:665
Iterator iter_
Definition: rah.hpp:1266
I end() const
Definition: rah.hpp:87
bool equal(sliding_iterator const &r) const
Definition: rah.hpp:490
join_iterator(U &&range, Iterator1 rangeIter, Iterator2 subRangeIter, Iterator2 subRangeEnd)
Definition: rah.hpp:751
Definition: rah - Copie.hpp:630
#define assert(CONDITION)
Definition: test.cpp:40
Definition: rah - Copie.hpp:1158
void increment()
Definition: rah.hpp:784
bool operator==(I other) const
Definition: rah.hpp:311
bool equal(concat_iterator other) const
Definition: rah.hpp:1370
void increment()
Definition: rah.hpp:438
I begin() const
Definition: rah.hpp:85
bool none_of(R &&range, P &&pred)
Checks if unary predicate pred returns true for no elements in the range.
Definition: rah - Copie.hpp:1476
range_begin_type_t< R > Iterator
Definition: rah.hpp:1264
void increment()
Definition: rah.hpp:1349
bool equal(unbounded_iterator r) const
Definition: rah.hpp:637
rah ::details::optional< F > func_
Definition: rah.hpp:1268
auto dereference() const -> decltype(*iter_)
Definition: rah.hpp:1315
Definition: rah - Copie.hpp:1047
optional & operator=(T &&other)
Definition: rah.hpp:202
bool equal(generate_iterator) const
Definition: rah.hpp:885
void set_intersection(IN1 &&in1, IN2 &&in2, OUT_ &&out)
Copies the elements from the sorted range in1 which are also found in the sorted range in2 to the ran...
Definition: rah.hpp:2258
unbounded_iterator(I iter, bool end)
Definition: rah.hpp:612
auto operator[](intptr_t increment) const
Definition: rah.hpp:376
constexpr intptr_t End
Used with rah::view::slice to point to the end.
Definition: rah - Copie.hpp:45
void increment()
Definition: rah.hpp:1199
auto copy_if(R1 &&in, R2 &&out, P &&pred)
Copies the elements for which the predicate pred returns true.
Definition: rah - Copie.hpp:1693
repeat_iterator(U val)
Definition: rah.hpp:720
void increment()
Definition: rah.hpp:1301
auto mismatch(R1 &&range1, R2 &&range2)
Finds the first position where two ranges differ.
Definition: rah - Copie.hpp:1569
auto size(R &&range)
Get the size of range.
Definition: rah - Copie.hpp:1714
auto dereference() const
Definition: rah.hpp:484
I end()
Definition: rah.hpp:88
T * type
Definition: rah - Copie.hpp:147
auto enumerate(R &&range)
Pair each element of a range with its index.
Definition: rah - Copie.hpp:1232
auto min_element(P &&pred)
Finds the smallest element in the range.
Definition: rah.hpp:1878
bool equal(stride_iterator other) const
Definition: rah.hpp:1074
auto distance_to(ints_iterator other) const
Definition: rah.hpp:667
auto all(R &&range)
Create a view on the whole range.
Definition: rah - Copie.hpp:407
auto dereference() const -> decltype(*first1_)
Definition: rah.hpp:983
void decrement()
Definition: rah.hpp:724
Definition: rah - Copie.hpp:881
auto dereference() const -> decltype(*iter_)
Definition: rah.hpp:1073
zip_iterator(IterTuple const &iters)
Definition: rah.hpp:1198
typename std ::iterator_traits< range_begin_type_t< R > >::iterator_category range_iter_categ_t
Definition: rah - Copie.hpp:69
generate_iterator(F const &func)
Definition: rah.hpp:881
auto distance_to(stride_iterator other) const
Definition: rah.hpp:1075
typename pointer_type< R >::type pointer
Definition: rah - Copie.hpp:153
void advance(intptr_t value)
Definition: rah.hpp:723
bool equal(take_iterator r) const
Definition: rah.hpp:443
T * operator->()
Definition: rah.hpp:227
Definition: rah - Copie.hpp:607
bool equal(repeat_iterator) const
Definition: rah.hpp:726
R reference
Definition: rah - Copie.hpp:184
#define RAH_STD
Definition: rah.hpp:29
I subRangeLast_
Definition: rah.hpp:471
InputIt2 last2_
Definition: rah.hpp:954
auto dereference() const -> decltype(*iter_)
Definition: rah.hpp:574
void advance(intptr_t value)
Definition: rah.hpp:695
auto operator=(V &&value) const
Definition: rah.hpp:314
auto cycle(R &&range)
Returns an infinite range that endlessly repeats the source range.
Definition: rah - Copie.hpp:749
auto dereference() const -> decltype(*std ::get< 0 >(iter_))
Definition: rah.hpp:1362
auto make_iterator_range(I b, I e)
Create a rah::iterator_range with two given iterators.
Definition: rah - Copie.hpp:92
auto & operator++()
Definition: rah.hpp:278
Iterator begin_
Definition: rah.hpp:1265
auto join(R &&range_of_ranges)
Given a range of ranges, join them into a flattened sequence of elements.
Definition: rah - Copie.hpp:691
bool equal(counted_iterator r) const
Definition: rah.hpp:575
auto sort(R &&range, P &&pred={})
Make a sorted view of a range.
Definition: rah - Copie.hpp:1282
auto take(R &&range, size_t count)
Given a source range and an integral count, return a range consisting of the first count elements fro...
Definition: rah - Copie.hpp:440
void next_valid()
Definition: rah.hpp:768
auto iota(T b, T e, T step=1)
Generate a range of sequential integers, increasing by a defined step.
Definition: rah - Copie.hpp:595
auto count_if(R &&range, P &&pred)
Counts elements for which predicate pred returns true.
Definition: rah - Copie.hpp:1513
Definition: rah - Copie.hpp:768
void advance(intptr_t value)
Definition: rah.hpp:1072
auto back_insert(R1 &&in, R2 &&out)
Insert in in back of front
Definition: rah - Copie.hpp:1673
void increment()
Definition: rah.hpp:570
T * begin(T(&array)[N])
Definition: rah - Copie.hpp:49
auto make_pipeable(MakeRange &&make_range)
Call to create a "pipeable" function (UFCS style in c++)
Definition: rah - Copie.hpp:115
std ::remove_reference_t< R > value_type
Definition: rah - Copie.hpp:181
auto operator-(intptr_t increment)
Definition: rah.hpp:364
auto reduce(R &&range, I &&init, F &&reducer)
Executes a reducer function on each element of the range, resulting in a single output value.
Definition: rah - Copie.hpp:1418
auto dereference() const
Definition: rah.hpp:1202
back_insert_iterator(C &container)
Definition: rah.hpp:386
auto find_if(R &&range, P &&pred)
Finds the first element satisfying specific criteria.
Definition: rah - Copie.hpp:1596
optional(T const &other)
Definition: rah.hpp:191
bool operator>=(I other) const
Definition: rah.hpp:375
bool operator!=(I other) const
Definition: rah.hpp:310
auto find(R &&range, V &&value)
Finds the first element equal to value.
Definition: rah - Copie.hpp:1579
auto dereference() const
Definition: rah.hpp:698
decltype(begin(fake< T >())) range_begin_type_t
Definition: rah - Copie.hpp:57
auto concat(R1 &&range1)
return the same range
Definition: rah - Copie.hpp:1202
std ::forward_iterator_tag iterator_category
Definition: rah - Copie.hpp:180
auto retro(R &&range)
Create a view that traverses the source range in reverse order.
Definition: rah - Copie.hpp:924
auto stride(R &&range, size_t step)
Create a view consisting of every Nth element, starting with the first.
Definition: rah - Copie.hpp:909
cycle_iterator(U &&range, Iterator iter)
Definition: rah.hpp:837
void reset()
Definition: rah.hpp:212
void advance(intptr_t off)
Definition: rah.hpp:481
Definition: rah - Copie.hpp:456
auto equal(R1 &&range1, R2 &&range2)
Determines if two sets of elements are the same.
Definition: rah - Copie.hpp:1733
bool operator>(I other) const
Definition: rah.hpp:374
I subRangeBegin_
Definition: rah.hpp:470
bool equal(join_iterator other) const
Definition: rah.hpp:790
Inerit to make an iterator.
Definition: rah - Copie.hpp:128
auto & operator-=(intptr_t increment)
Definition: rah.hpp:358
bool operator!=(I other) const
Definition: rah.hpp:290
auto operator|(R &&range, pipeable< MakeRange > const &adapter) -> decltype(adapter.func(std ::forward< R >(range)))
Definition: rah - Copie.hpp:121
auto operator->() const
Definition: rah.hpp:289
stream_inserter_iterator(S &stream)
Definition: rah.hpp:2014
sliding_iterator(I subRangeBegin, I subRangeLast)
Definition: rah.hpp:474
InputIt1 first1_
Definition: rah.hpp:951
void decrement()
Definition: rah.hpp:482
auto back_inserter(C &&container)
Make a range which insert into the back of the a container.
Definition: rah - Copie.hpp:276
void advance(intptr_t off)
Definition: rah.hpp:571
auto dereference() const
Definition: rah.hpp:668
optional & operator=(T const &other)
Definition: rah.hpp:196
T & fake()
Used in decltype to get an instance of a type.
Definition: rah - Copie.hpp:54
auto dereference() const
Definition: rah.hpp:1240
chunk_iterator(range_begin_type_t< R > const &iter, range_begin_type_t< R > const &iter2, range_end_type_t< R > const &end, size_t step=0)
Definition: rah.hpp:1224
bool empty(R &&range)
Check if the range if empty.
Definition: rah - Copie.hpp:1313
void increment()
Definition: rah.hpp:1233
auto distance_to(sliding_iterator const &r) const
Definition: rah.hpp:483
value_type * pointer
Definition: rah - Copie.hpp:183
Definition: rah - Copie.hpp:1092
void put(V &&value) const
Definition: rah.hpp:387
auto ints(T b=0, T e=std ::numeric_limits< T >::max())
Generate a range of monotonically increasing ints.
Definition: rah - Copie.hpp:570
intptr_t difference_type
Definition: rah - Copie.hpp:152
void decrement()
Definition: rah.hpp:1307
auto decrement()
Definition: rah.hpp:1066
take_iterator(I iter, size_t count)
Definition: rah.hpp:436
auto operator-(I other) const
Definition: rah.hpp:371
auto drop(size_t count)
Given a source range and an integral count, return a range consisting of all but the first count elem...
Definition: rah.hpp:550
void next_value()
Definition: rah.hpp:1292
void decrement()
Definition: rah.hpp:440
optional(optional const &other)
Definition: rah.hpp:135
Definition: rah - Copie.hpp:719
T const & get() const
Definition: rah.hpp:223
InputIt2 first2_
Definition: rah.hpp:953
bool operator==(I other) const
Definition: rah.hpp:291
void increment()
Definition: rah.hpp:883
intptr_t difference_type
Definition: rah - Copie.hpp:182
bool equal(cycle_iterator) const
Definition: rah.hpp:852
stride_iterator(range_begin_type_t< R > const &iter, range_end_type_t< R > const &end, size_t step)
Definition: rah.hpp:1057
V const & dereference() const
Definition: rah.hpp:725
void increment()
Definition: rah.hpp:978
Definition: rah - Copie.hpp:1020
bool equal(set_difference_iterator r) const
Definition: rah.hpp:984
Definition: rah - Copie.hpp:636
auto stream_inserter(S &&stream)
Make a range which output to a stream.
Definition: rah - Copie.hpp:1765
void decrement()
Definition: rah.hpp:1201
auto counted(I &&it, size_t n, decltype(++it, 0)=0)
Given an iterator it and a count n, create a range that starts at it and includes the next n elements...
Definition: rah - Copie.hpp:476
I begin()
Definition: rah.hpp:86
bool equal(ints_iterator other) const
Definition: rah.hpp:669
range_begin_type_t< decltype(*fake< Iterator1 >())> Iterator2
Definition: rah - Copie.hpp:634
void increment()
Definition: rah.hpp:614
auto remove_if(R &&range, P &&pred)
Keep at the begining of the range only elements for which pred(elt) is false .
Definition: rah - Copie.hpp:1779
void next_value()
Definition: rah.hpp:962
static auto get(V *ptr)
Definition: rah.hpp:1279
bool all_of(R &&range, P &&pred)
Checks if unary predicate pred returns true for all elements in the range.
Definition: rah - Copie.hpp:1457
auto remove(V &&value)
Keep only elements not equal to value.
Definition: rah.hpp:2334
auto distance_to(take_iterator r) const
Definition: rah.hpp:441
decltype(*begin(fake< T >())) range_ref_type_t
Definition: rah - Copie.hpp:63
~optional()
Definition: rah.hpp:208
rah ::details::optional< Reference > type
Definition: rah.hpp:248
auto to_container(R &&range)
Return a container of type C, filled with the content of range.
Definition: rah - Copie.hpp:1550
auto slice(R &&range, intptr_t begin_idx, intptr_t end_idx)
Create a view that is a sub-range of a range.
Definition: rah - Copie.hpp:848
auto filter(R &&range, F &&func)
Create a view with only elements which are filtered.
Definition: rah - Copie.hpp:1139
void increment()
Definition: rah.hpp:694
auto map_value(R &&range)
Given a range of std::pair-std::tuple, create a view consisting of just the first element of the pair...
Definition: rah - Copie.hpp:1245
Definition: rah - Copie.hpp:420
auto & operator+=(intptr_t increment)
Definition: rah.hpp:345
auto partition(R &&range, P &&pred)
Reorders the elements in the range in such a way that all elements for which the predicate pred retur...
Definition: rah - Copie.hpp:1802
void put(V &&value) const
Definition: rah.hpp:2015
void increment()
Definition: rah.hpp:845
void shuffle(R &range, URBG &&g)
Reorders the elements in the given range such that each possible permutation of those elements has eq...
Definition: rah - Copie.hpp:1913
auto zip(R &&... _ranges)
Given N ranges, return a new range where Mth element is the result of calling std::make_tuple on the ...
Definition: rah - Copie.hpp:1037
std ::remove_reference_t< R > value_type
Definition: rah - Copie.hpp:151
Definition: rah - Copie.hpp:579
bool operator<=(I other) const
Definition: rah.hpp:373
auto copy(R1 &&in, R2 &&out)
Copy in range into an other.
Definition: rah - Copie.hpp:1633
auto & operator--()
Definition: rah.hpp:330
bool any_of(R &&range, F &&pred)
Checks if unary predicate pred returns true for at least one element in the range.
Definition: rah - Copie.hpp:1438
bool operator<(I other) const
Definition: rah.hpp:372
std ::forward_iterator_tag iterator_category
Definition: rah - Copie.hpp:150
T * end(T(&array)[N]) noexcept
Definition: rah - Copie.hpp:51
filter_iterator(range_begin_type_t< R > const &begin, range_begin_type_t< R > const &iter, range_end_type_t< R > const &end, F func)
Definition: rah.hpp:1282
void advance(intptr_t off)
Definition: rah.hpp:439
auto distance_to(unbounded_iterator r) const
Definition: rah.hpp:618
rah ::details::optional< F > func_
Definition: rah.hpp:879
T & get()
Definition: rah.hpp:221
set_difference_iterator(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2)
Definition: rah.hpp:956
auto count(R &&range, V &&value)
Counts the elements that are equal to value.
Definition: rah - Copie.hpp:1495
range_begin_type_t< R > Iterator1
Definition: rah - Copie.hpp:633
join_iterator(U &&range, Iterator1 rangeIter)
Definition: rah.hpp:762
auto unique(R &&range, P &&pred={})
Remove all but first successuve values which are equals.
Definition: rah - Copie.hpp:1942
auto erase(C &&container, R &&subrange)
Erase a sub-range of a given container.
Definition: rah - Copie.hpp:1844
range_begin_type_t< R > Iterator
Definition: rah - Copie.hpp:722
iota_iterator(T val, T step)
Definition: rah.hpp:692
void increment()
Definition: rah.hpp:480
void decrement()
Definition: rah.hpp:572
static type to_pointer(Ref &&ref)
Definition: rah.hpp:261
bool equal(zip_iterator other) const
Definition: rah.hpp:1204
void increment()
Definition: rah.hpp:664
#define RAH_NAMESPACE
Definition: rah.hpp:39
static auto get(I const &iter)
Definition: rah.hpp:1275
bool equal(iota_iterator other) const
Definition: rah.hpp:699
bool operator()(A &&a, B &&b)
Definition: rah.hpp:2210
void advance(intptr_t off)
Definition: rah.hpp:616
auto for_each(R &&range, F &&func)
Lazily applies an unary function to each element in the source range that returns another range (poss...
Definition: rah - Copie.hpp:835
std ::iterator_traits< range_begin_type_t< R > >::pointer value_pointer_
Definition: rah.hpp:1269
auto increment()
Definition: rah.hpp:1060
auto repeat(V &&value)
Generate an infinite range of the given value.
Definition: rah - Copie.hpp:622
auto unbounded(I &&it)
Given an iterator, return an infinite range that begins at that position.
Definition: rah - Copie.hpp:543
auto single(V &&value)
Given value, create a view containing one element.
Definition: rah - Copie.hpp:938
auto find_if_not(R &&range, P &&pred)
Finds the first element not satisfying specific criteria.
Definition: rah - Copie.hpp:1613