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; };
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; }
108 template<
typename Func>
114 template<
typename MakeRange>
120 template<
typename R,
typename MakeRange>
123 return adapter.func(RAH_STD::forward<R>(range));
130 template<
typename I,
typename R>
133 template <
class Reference>
140 operator Reference
const*()
const {
return &m_ref; }
145 struct pointer_type<T&>
156 static_assert(not RAH_STD::is_reference<value_type>::value,
"value_type can't be a reference");
158 I&
self() {
return *static_cast<I*>(
this); }
159 I
const&
self()
const {
return *static_cast<I const*>(
this); }
169 static_assert(RAH_STD::is_same<decltype(
self().dereference()),
reference>::value,
"");
170 return self().dereference();
177 template<
typename I,
typename R>
186 static_assert(not RAH_STD::is_reference<value_type>::value,
"value_type can't be a reference");
188 I&
self() {
return *static_cast<I*>(
this); }
189 I
const&
self()
const {
return *static_cast<I const*>(
this); }
192 auto& operator*()
const {
return *
this; }
199 self().put(RAH_STD::forward<V>(value));
205 template<
typename I,
typename R>
210 I&
self() {
return *static_cast<I*>(
this); }
211 I
const&
self()
const {
return *static_cast<I const*>(
this); }
220 template<
typename I,
typename R>
225 I&
self() {
return *static_cast<I*>(
this); }
226 I
const&
self()
const {
return *static_cast<I const*>(
this); }
230 self().advance(increment);
237 iter.advance(increment);
243 self().advance(-increment);
250 iter.advance(-increment);
254 auto operator-(I other)
const {
return self().distance_to(other); }
255 bool operator<(I other)
const {
return self().distance_to(other) < 0; }
256 bool operator<=(I other)
const {
return self().distance_to(other) <= 0; }
257 bool operator>(I other)
const {
return self().distance_to(other) > 0; }
258 bool operator>=(I other)
const {
return self().distance_to(other) >= 0; }
259 auto operator[](intptr_t increment)
const {
return *(
self() + increment); }
270 template<
typename V>
void put(V&& value)
const { container_->emplace_back(value); }
278 using Container = RAH_STD::remove_reference_t<C>;
287 template<
typename A,
typename B>
bool operator()(A&& a, B&& b) {
return a < b; }
304 new(getPtr()) T(other.
get());
305 is_allocated_ =
true;
316 new(getPtr()) T(other.
get());
317 is_allocated_ =
true;
326 new(getPtr()) T(other.
get());
327 is_allocated_ =
true;
336 if (other.has_value())
340 new(getPtr()) T(RAH_STD::move(other.get()));
341 is_allocated_ =
true;
348 if (other.has_value())
350 new(getPtr()) T(RAH_STD::move(other.get()));
351 is_allocated_ =
true;
358 new(getPtr()) T(other);
359 is_allocated_ =
true;
363 new(getPtr()) T(other);
364 is_allocated_ =
true;
369 new(getPtr()) T(RAH_STD::move(other));
370 is_allocated_ =
true;
382 is_allocated_ =
false;
388 T
const&
get()
const {
assert(is_allocated_);
return *getPtr(); }
390 T& operator*() {
return get(); }
391 T
const& operator*()
const {
return get(); }
396 T* getPtr() {
return (T*)&value_; }
397 T
const* getPtr()
const {
return (T
const*)&value_; }
398 void destruct_value() { get().~T(); }
400 RAH_STD::aligned_storage_t<
sizeof(T), RAH_STD::alignment_of<T>::value> value_;
401 bool is_allocated_ =
false;
407 template<
typename R>
auto all(R&& range)
422 decltype(*fake<I>()),
423 typename RAH_STD::iterator_traits<I>::iterator_category
427 size_t count_ = size_t();
433 void advance(intptr_t off) { iter_ += off; count_ += off; }
443 iterator iter1(
begin(range), 0);
458 decltype(*fake<I>()),
459 typename RAH_STD::iterator_traits<I>::iterator_category
463 size_t count_ = size_t();
469 void advance(intptr_t off) { iter_ += off; count_ += off; }
476 template<
typename I>
auto counted(I&& it,
size_t n, decltype(++it, 0) = 0)
479 iterator iter1(it, 0);
480 iterator iter2(it, n);
486 template<
typename R>
auto counted(R&& range,
size_t n, decltype(
begin(range), 0) = 0)
488 return take(range, n);
501 unbounded_iterator<I>,
502 decltype(*fake<I>()),
503 typename RAH_STD::iterator_traits<I>::iterator_category
523 return RAH_STD::numeric_limits<intptr_t>::min();
528 return RAH_STD::numeric_limits<intptr_t>::max();
530 return iter_ - r.
iter_;
546 iterator iter1(it,
false);
547 iterator iter2(it,
true);
554 template<
typename T =
size_t>
563 void advance(intptr_t value) { val_ += T(value); }
570 template<
typename T =
size_t>
auto ints(T b = 0, T e = RAH_STD::numeric_limits<T>::max())
578 template<
typename T =
size_t>
588 void advance(intptr_t value) { val_ += T(step_ * value); }
595 template<
typename T =
size_t>
auto iota(T b, T e, T step = 1)
599 diff = ((diff + (step - 1)) / step) * step;
622 template<
typename V>
auto repeat(V&& value)
645 : range_(
RAH_STD::forward<U>(range))
646 , rangeIter_(rangeIter)
647 , subRange_(
SubRange{ subRangeIter, subRangeEnd })
649 if (rangeIter_ ==
end(range_))
656 : range_(
RAH_STD::forward<U>(range))
657 , rangeIter_(rangeIter)
663 while (subRange_->subRangeIter == subRange_->subRangeEnd)
666 if (rangeIter_ ==
end(range_))
670 subRange_->subRangeIter =
begin(*rangeIter_);
671 subRange_->subRangeEnd =
end(*rangeIter_);
678 ++subRange_->subRangeIter;
681 auto dereference() const ->decltype(*subRange_->subRangeIter) {
return *subRange_->subRangeIter; }
684 if (rangeIter_ ==
end(range_))
687 return rangeIter_ == other.
rangeIter_ && subRange_->subRangeIter == other.
subRange_->subRangeIter;
691 template<
typename R>
auto join(R&& range_of_ranges)
694 using join_iterator_type =
join_iterator<decltype(rangeRef)>;
695 auto rangeBegin =
begin(rangeRef);
696 auto rangeEnd =
end(rangeRef);
699 join_iterator_type b(rangeRef, rangeBegin);
700 join_iterator_type e(rangeRef, rangeEnd);
705 join_iterator_type b(rangeRef, rangeBegin,
begin(*rangeBegin),
end(*rangeBegin));
706 join_iterator_type e(rangeRef, rangeEnd);
729 : range_(
RAH_STD::forward<U>(range))
730 , beginIter_(
begin(range_))
731 , endIter_(
end(range_))
739 while (iter_ == endIter_)
740 iter_ =
begin(range_);
749 template<
typename R>
auto cycle(R&& range)
752 using iterator_type =
cycle_iterator<RAH_STD::remove_reference_t<decltype(rangeRef)>>;
754 iterator_type b(rangeRef,
begin(rangeRef));
755 iterator_type e(rangeRef,
begin(rangeRef));
781 using Functor = RAH_STD::remove_cv_t<RAH_STD::remove_reference_t<F>>;
792 template<
typename R,
typename F>
794 transform_iterator<R, F>,
795 decltype(fake<F>()(fake<range_ref_type_t<R>>())),
796 range_iter_categ_t<R>
815 auto dereference() const -> decltype((*func_)(*iter_)) {
return (*func_)(*iter_); }
819 template<
typename R,
typename F>
auto transform(R&& range, F&& func)
821 using Functor = RAH_STD::remove_cv_t<RAH_STD::remove_reference_t<F>>;
823 auto iter1 =
begin(range);
824 auto iter2 =
end(range);
835 template<
typename R,
typename F>
auto for_each(R&& range, F&& func)
848 template<
typename R>
auto slice(R&& range, intptr_t begin_idx, intptr_t end_idx)
851 "Can't use slice on non-bidirectional iterators. Try to use view::drop and view::take");
852 auto findIter = [](
auto b,
auto e, intptr_t idx)
857 RAH_STD::advance(e, idx);
862 RAH_STD::advance(b, idx);
866 auto b_in =
begin(range);
867 auto e_in =
end(range);
868 auto b_out = findIter(b_in, e_in, begin_idx);
869 auto e_out = findIter(b_in, e_in, end_idx);
888 : iter_(iter), end_(
end), step_(step) {}
892 for (
size_t i = 0; i < step_ && iter_ != end_; ++i)
898 for (
size_t i = 0; i < step_; ++i)
902 void advance(intptr_t value) { iter_ += step_ * value; }
909 template<
typename R>
auto stride(R&& range,
size_t step)
911 auto iter =
begin(range);
912 auto endIter =
end(range);
914 { iter, endIter, step}, { endIter, endIter, step }};
924 template<
typename R>
auto retro(R&& range)
927 RAH_STD::make_reverse_iterator(
end(range)), RAH_STD::make_reverse_iterator(
begin(range)));
947 template <
typename Tuple,
typename F,
size_t ...Indices>
948 void for_each_impl(Tuple&& tuple, F&& f, RAH_STD::index_sequence<Indices...>)
950 using swallow =
int[];
953 (f(RAH_STD::get<Indices>(RAH_STD::forward<Tuple>(tuple))), void(),
int{})...
957 template <
typename Tuple,
typename F>
960 constexpr
size_t N = RAH_STD::tuple_size<RAH_STD::remove_reference_t<Tuple>>::value;
961 for_each_impl(RAH_STD::forward<Tuple>(tuple), RAH_STD::forward<F>(f),
962 RAH_STD::make_index_sequence<N>{});
965 template <
class F,
typename... Args,
size_t... Is>
966 auto transform_each_impl(
const RAH_STD::tuple<Args...>& t, F&& f, RAH_STD::index_sequence<Is...>) {
967 return RAH_STD::make_tuple(
968 f(RAH_STD::get<Is>(t))...
972 template <
class F,
typename... Args>
973 auto transform_each(
const RAH_STD::tuple<Args...>& t, F&& f) {
974 return transform_each_impl(
975 t, RAH_STD::forward<F>(f), RAH_STD::make_index_sequence<
sizeof...(Args)>{});
978 template <
typename... Args,
size_t... Is>
979 auto deref_impl(
const RAH_STD::tuple<Args...>& t, RAH_STD::index_sequence<Is...>) {
980 return RAH_STD::tuple<typename RAH_STD::iterator_traits<Args>::reference...>(
981 (*RAH_STD::get<Is>(t))...
985 template <
typename... Args>
986 auto deref(
const RAH_STD::tuple<Args...>& t) {
987 return deref_impl(t, RAH_STD::make_index_sequence<
sizeof...(Args)>{});
990 template <
size_t Index>
993 template <
typename... Args>
994 bool operator()(RAH_STD::tuple<Args...>
const& a, RAH_STD::tuple<Args...>
const& b)
const 996 return (RAH_STD::get<Index - 1>(a) == RAH_STD::get<Index - 1>(b)) || Equal<Index - 1>{}(a, b);
1003 template <
typename... Args>
1004 bool operator()(RAH_STD::tuple<Args...>
const&, RAH_STD::tuple<Args...>
const&)
const 1010 template <
typename... Args>
1011 auto equal(RAH_STD::tuple<Args...>
const& a, RAH_STD::tuple<Args...>
const& b)
1013 return Equal<
sizeof...(Args)>{}(a, b);
1019 template<
typename IterTuple>
1021 zip_iterator<IterTuple>,
1022 decltype(details::deref(fake<IterTuple>())),
1023 RAH_STD::bidirectional_iterator_tag
1037 template<
typename ...R>
auto zip(R&&... _ranges)
1039 auto iterTup = RAH_STD::make_tuple(
begin(RAH_STD::forward<R>(_ranges))...);
1040 auto endTup = RAH_STD::make_tuple(
end(RAH_STD::forward<R>(_ranges))...);
1046 template<
typename R>
1059 : iter_(iter), iter2_(iter2), end_(
end), step_(step)
1066 for (
size_t i = 0; i != step_ and iter2_ != end_; ++i)
1074 template<
typename R>
auto chunk(R&& range,
size_t step)
1076 auto iter =
begin(range);
1077 auto endIter =
end(range);
1079 iterator
begin = { iter, iter, endIter, step };
1091 template<
typename R,
typename F>
1105 : begin_(
begin), iter_(iter), end_(
end), func_(func)
1112 value_pointer_ = iter_.operator->();
1113 while (iter_ != end_ && not (*func_)(**value_pointer_))
1117 value_pointer_ = iter_.operator->();
1132 }
while (not (*func_)(*iter_) && iter_ != begin_);
1135 auto dereference() const -> decltype(*iter_) {
return **value_pointer_; }
1139 template<
typename R,
typename F>
auto filter(R&& range, F&& func)
1141 auto iter =
begin(range);
1142 auto endIter =
end(range);
1143 using Predicate = RAH_STD::remove_cv_t<RAH_STD::remove_reference_t<F>>;
1145 { iter, iter, endIter, func },
1146 { iter, endIter, endIter, func }
1157 template<
typename IterPair,
typename V>
1165 : iter_(iter), end_(
end), range_index_(range_index)
1171 if (range_index_ == 0)
1173 auto& i = RAH_STD::get<0>(iter_);
1175 if (i == RAH_STD::get<0>(end_))
1179 ++RAH_STD::get<1>(iter_);
1184 if (range_index_ == 0)
1185 return *RAH_STD::get<0>(iter_);
1187 return *RAH_STD::get<1>(iter_);
1194 if (range_index_ == 0)
1195 return RAH_STD::get<0>(iter_) == RAH_STD::get<0>(other.
iter_);
1197 return RAH_STD::get<1>(iter_) == RAH_STD::get<1>(other.
iter_);
1202 template<
typename R1>
auto concat(R1&& range1)
1204 return RAH_STD::forward<R1>(range1);
1207 template<
typename R1,
typename R2>
auto concat(R1&& range1, R2&& range2)
1209 auto begin_range1 = RAH_STD::make_pair(
begin(range1),
begin(range2));
1210 auto begin_range2 = RAH_STD::make_pair(
end(range1),
end(range2));
1211 auto end_range1 = RAH_STD::make_pair(
end(range1),
end(range2));
1212 auto end_range2 = RAH_STD::make_pair(
end(range1),
end(range2));
1218 { begin_range1, begin_range2, 0 },
1219 { end_range1, end_range2, 1 },
1224 template<
typename R1,
typename R2,
typename ...Ranges>
1225 auto concat(R1&& range1, R2&& range2, Ranges&&... ranges)
1227 return concat(
concat(RAH_STD::forward<R1>(range1), RAH_STD::forward<R2>(range2)), ranges...);
1234 size_t const dist = RAH_STD::distance(
begin(RAH_STD::forward<R>(range)),
end(RAH_STD::forward<R>(range)));
1235 return zip(
iota(
size_t(0), dist), RAH_STD::forward<R>(range));
1247 return transform(RAH_STD::forward<R>(range), [](
auto&& nvp) -> decltype(RAH_STD::get<1>(RAH_STD::forward<decltype(nvp)>(nvp)))
1249 return RAH_STD::get<1>(RAH_STD::forward<decltype(nvp)>(nvp));
1262 return RAH_NAMESPACE::view::transform(RAH_STD::forward<R>(range), [](
auto&& nvp) -> decltype(RAH_STD::get<0>(RAH_STD::forward<decltype(nvp)>(nvp)))
1264 return RAH_STD::get<0>(RAH_STD::forward<decltype(nvp)>(nvp));
1281 template<typename R, typename P = is_lesser, typename = RAH_STD::enable_if_t<is_range<R>::value>>
1282 auto sort(R&& range, P&& pred = {})
1285 using Container =
typename RAH_STD::vector<value_type>;
1287 result.reserve(RAH_STD::distance(
begin(range),
end(range)));
1300 template<typename P = is_lesser, typename = RAH_STD::enable_if_t<not is_range<P>::value>>
1303 return make_pipeable([=](
auto&& range) {
return view::sort(RAH_STD::forward<decltype(range)>(range), pred); });
1313 template<
typename R>
bool empty(R&& range)
1332 template<
typename R,
typename V>
1352 template<
typename R,
typename V,
typename P>
1364 template<
typename V,
typename P>
1367 return make_pipeable([=](
auto&& range) {
return equal_range(RAH_STD::forward<decltype(range)>(range), value, pred); });
1394 template<
typename RI,
typename RO,
typename F>
1403 template<
typename RI1,
typename RI2,
typename RO,
typename F>
1404 auto transform(RI1&& rangeIn1, RI2&& rangeIn2, RO&& rangeOut, F&& binary_op)
1410 RAH_STD::forward<F>(binary_op));
1418 template<
typename R,
typename I,
typename F>
auto reduce(R&& range, I&& init, F&& reducer)
1420 return RAH_STD::accumulate(
begin(range),
end(range), RAH_STD::forward<I>(init), RAH_STD::forward<F>(reducer));
1427 template<
typename I,
typename F>
1438 template<
typename R,
typename F>
bool any_of(R&& range, F&& pred)
1457 template<
typename R,
typename P>
bool all_of(R&& range, P&& pred)
1476 template<
typename R,
typename P>
bool none_of(R&& range, P&& pred)
1495 template<
typename R,
typename V>
auto count(R&& range, V&& value)
1504 template<
typename V>
auto count(V&& value)
1513 template<
typename R,
typename P>
auto count_if(R&& range, P&& pred)
1531 template<
typename R,
typename F>
auto for_each(R&& range, F&& func)
1552 return C(
begin(range),
end(range));
1561 return make_pipeable([=](
auto&& range) {
return to_container<C>(range); });
1569 template<
typename R1,
typename R2>
auto mismatch(R1&& range1, R2&& range2)
1579 template<
typename R,
typename V>
auto find(R&& range, V&& value)
1588 template<
typename V>
auto find(V&& value)
1596 template<
typename R,
typename P>
auto find_if(R&& range, P&& pred)
1613 template<
typename R,
typename P>
auto find_if_not(R&& range, P&& pred)
1633 template<
typename R1,
typename R2>
auto copy(R1&& in, R2&& out)
1643 template<
typename R2>
auto copy(R2&& out)
1654 template<
typename R1,
typename V>
auto fill(R1&& in, V&& value)
1663 template<
typename V>
auto fill(V&& value)
1673 template<
typename R1,
typename R2>
auto back_insert(R1&& in, R2&& out)
1693 template<
typename R1,
typename R2,
typename P>
auto copy_if(R1&& in, R2&& out, P&& pred)
1703 template<
typename R2,
typename P>
auto copy_if(R2&& out, P&& pred)
1714 template<
typename R>
auto size(R&& range)
1716 return RAH_STD::distance(
begin(range),
end(range));
1733 template<
typename R1,
typename R2>
auto equal(R1&& range1, R2&& range2)
1735 #ifdef EASTL_VERSION 1736 return RAH_STD::identical(
begin(range1),
end(range1),
begin(range2),
end(range2));
1746 template<
typename R1>
auto equal(R1&& range2)
1749 return make_pipeable([=](
auto&& range1) {
return equal(RAH_STD::forward<decltype(range1)>(range1), all_range2); });
1754 template<
typename S>
1759 template<
typename V>
void put(V&& value)
const { (*stream_) << value; }
1767 using Stream = RAH_STD::remove_reference_t<S>;
1779 template<
typename R,
typename P>
auto remove_if(R&& range, P&& pred)
1802 template<
typename R,
typename P>
auto partition(R&& range, P&& pred)
1844 template<
typename C,
typename R>
auto erase(C&& container, R&& subrange)
1846 container.erase(
begin(subrange),
end(subrange));
1855 template<
typename R>
auto erase(R&& range)
1867 template<typename R, typename P = is_lesser, typename = RAH_STD::enable_if_t<is_range<R>::value>>
1878 template<typename P = is_lesser, typename = RAH_STD::enable_if_t<not is_range<P>::value>>
1890 template<typename R, typename P = is_lesser, typename = RAH_STD::enable_if_t<is_range<R>::value>>
1901 template<typename P = is_lesser, typename = RAH_STD::enable_if_t<not is_range<P>::value>>
1912 template<
typename R,
typename URBG>
1922 template<
typename URBG>
1933 template<
typename A,
typename B>
bool operator()(A&& a, B&& b) {
return a == b; }
1941 template<typename R, typename P = is_equal, typename = RAH_STD::enable_if_t<is_range<R>::value>>
1953 template<typename P = is_equal, typename = RAH_STD::enable_if_t<not is_range<P>::value>>
1956 return make_pipeable([=](
auto&& range) {
return unique(RAH_STD::forward<decltype(range)>(range), pred); });
1965 template<
typename IN1,
typename IN2,
typename OUT>
1980 template<
typename IN1,
typename IN2,
typename OUT>
1999 template<typename C, typename P = is_equal, typename = RAH_STD::enable_if_t<is_range<C>::value>>
2003 return RAH_STD::forward<C>(container);
2012 template<typename P = is_equal, typename = RAH_STD::enable_if_t<not is_range<P>::value>>
2024 template<
typename C,
typename P>
auto&&
remove_if(C&& container, P&& pred)
2027 return RAH_STD::forward<C>(container);
2037 return make_pipeable([=](
auto&& range) ->
auto&& {
return remove_if(RAH_STD::forward<decltype(range)>(range), pred); });
2047 template<typename C, typename P = is_lesser, typename = RAH_STD::enable_if_t<is_range<C>::value>>
2048 auto&&
sort(C&& container, P&& pred = {})
2051 return RAH_STD::forward<C>(container);
2060 template<typename P = is_lesser, typename = RAH_STD::enable_if_t<not is_range<P>::value>>
2063 return make_pipeable([=](
auto&& range) ->
auto&& {
return action::sort(RAH_STD::forward<decltype(range)>(range), pred); });
2072 template<
typename C,
typename URBG>
2075 URBG gen = RAH_STD::forward<URBG>(g);
2077 return RAH_STD::forward<C>(container);
2085 template<
typename URBG>
2096 template<
typename R1,
typename V>
auto fill(R1&& in, V&& value)
2099 return RAH_STD::forward<R1>(in);
2106 template<
typename V>
auto fill(V&& value)
auto filter(F &&func)
Create a view with only elements which are filtered.
Definition: rah - Copie.hpp:1150
void decrement()
Definition: rah - Copie.hpp:564
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 - Copie.hpp:191
void decrement()
Definition: rah - Copie.hpp:589
auto distance_to(iota_iterator other) const
Definition: rah - Copie.hpp:590
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 - Copie.hpp:1981
auto dereference() const
Definition: rah - Copie.hpp:775
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 - Copie.hpp:1033
IterPair iter_
Definition: rah - Copie.hpp:1160
auto unique(P &&pred={})
Remove all but first successuve values which are equals.
Definition: rah - Copie.hpp:2013
counted_iterator(I iter, size_t count)
Definition: rah - Copie.hpp:466
auto distance_to(counted_iterator r) const
Definition: rah - Copie.hpp:471
auto dereference() const -> decltype(*iter_)
Definition: rah - Copie.hpp:534
T val_
Definition: rah - Copie.hpp:557
T * operator->()
Definition: rah - Copie.hpp:392
Definition: rah - Copie.hpp:500
void advance(intptr_t val)
Definition: rah - Copie.hpp:1030
concat_iterator(IterPair const &iter, IterPair const &end, size_t range_index)
Definition: rah - Copie.hpp:1164
auto concat(R1 &&range1, R2 &&range2, Ranges &&... ranges)
Definition: rah - Copie.hpp:1225
I end_iter
Definition: rah - Copie.hpp:83
bool operator()(A &&a, B &&b)
Definition: rah - Copie.hpp:287
optional(optional const &other)
Definition: rah - Copie.hpp:300
auto generate(F &&func)
Create an infinite range, repetitively calling func.
Definition: rah - Copie.hpp:779
auto operator+(intptr_t increment)
Definition: rah - Copie.hpp:234
optional & operator=(T const &other)
Definition: rah - Copie.hpp:361
auto dereference() const -> decltype(*subRange_->subRangeIter)
Definition: rah - Copie.hpp:681
ints_iterator(T val)
Definition: rah - Copie.hpp:560
R reference
Definition: rah - Copie.hpp:154
details::optional< F > func_
Definition: rah - Copie.hpp:770
decltype(end(fake< T >())) range_end_type_t
Definition: rah - Copie.hpp:60
bool equal(chunk_iterator other) const
Definition: rah - Copie.hpp:1071
T val_
Definition: rah - Copie.hpp:581
bool equal(filter_iterator other) const
Definition: rah - Copie.hpp:1136
auto back_insert(R2 &&out)
Insert in in back of front
Definition: rah - Copie.hpp:1682
auto enumerate()
Pair each element of a range with its index.
Definition: rah - Copie.hpp:1238
auto retro()
Create a view that traverses the source range in reverse order.
Definition: rah - Copie.hpp:930
auto all()
Create a view on the whole range.
Definition: rah - Copie.hpp:412
void increment()
Definition: rah - Copie.hpp:615
auto dereference() const -> decltype(*iter_)
Definition: rah - Copie.hpp:436
auto dereference() const -> decltype(*iter_)
Definition: rah - Copie.hpp:742
#define RAH_STD
Definition: rah - Copie.hpp:29
void decrement()
Definition: rah - Copie.hpp:515
void advance(intptr_t value)
Definition: rah - Copie.hpp:563
filter_iterator(range_begin_type_t< R > const &begin, range_begin_type_t< R > const &iter, range_end_type_t< R > const &end, F const &func)
Definition: rah - Copie.hpp:1100
Definition: rah - Copie.hpp:72
Apply the '<' operator on two values of any type.
Definition: rah - Copie.hpp:285
I end() const
Definition: rah - Copie.hpp:87
join_iterator(U &&range, Iterator1 rangeIter, Iterator2 subRangeIter, Iterator2 subRangeEnd)
Definition: rah - Copie.hpp:644
Definition: rah - Copie.hpp:630
auto reduce(I &&init, F &&reducer)
Executes a reducer function on each element of the range, resulting in a single output value.
Definition: rah - Copie.hpp:1428
#define assert(CONDITION)
Definition: test.cpp:40
range_end_type_t< R > end_
Definition: rah - Copie.hpp:1051
Definition: rah - Copie.hpp:1158
void increment()
Definition: rah - Copie.hpp:676
bool operator==(I other) const
Definition: rah - Copie.hpp:194
bool equal(concat_iterator other) const
Definition: rah - Copie.hpp:1190
auto transform(RI1 &&rangeIn1, RI2 &&rangeIn2, RO &&rangeOut, F &&binary_op)
The binary operation binary_op is applied to pairs of elements from two ranges.
Definition: rah - Copie.hpp:1404
void increment()
Definition: rah - Copie.hpp:432
I begin() const
Definition: rah - Copie.hpp:85
void increment()
Definition: rah - Copie.hpp:1169
bool equal(unbounded_iterator r) const
Definition: rah - Copie.hpp:535
auto count_if(P &&pred)
Counts elements for which predicate pred returns true.
Definition: rah - Copie.hpp:1521
auto dereference() const -> decltype(*iter_)
Definition: rah - Copie.hpp:1135
Definition: rah - Copie.hpp:1047
auto copy_if(R2 &&out, P &&pred)
Copies the elements for which the predicate pred returns true.
Definition: rah - Copie.hpp:1703
IterTuple iters_
Definition: rah - Copie.hpp:1026
bool equal(generate_iterator) const
Definition: rah - Copie.hpp:776
auto for_each(F &&func)
Applies the given function func to each element of the range.
Definition: rah - Copie.hpp:1540
auto take(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:448
unbounded_iterator(I iter, bool end)
Definition: rah - Copie.hpp:510
auto stable_sort(P &&pred={})
Sorts the elements in the range in ascending order.
Definition: rah - Copie.hpp:1902
auto operator[](intptr_t increment) const
Definition: rah - Copie.hpp:259
constexpr intptr_t End
Used with rah::view::slice to point to the end.
Definition: rah - Copie.hpp:45
void increment()
Definition: rah - Copie.hpp:1029
auto count(V &&value)
Counts the elements that are equal to value.
Definition: rah - Copie.hpp:1504
auto none_of(P &&pred)
Checks if unary predicate pred returns true for no elements in the range.
Definition: rah - Copie.hpp:1485
auto any_of(P &&pred)
Checks if unary predicate pred returns true for at least one element in the range.
Definition: rah - Copie.hpp:1447
repeat_iterator(U val)
Definition: rah - Copie.hpp:613
void increment()
Definition: rah - Copie.hpp:1121
auto mismatch(R1 &&range1, R2 &&range2)
Finds the first position where two ranges differ.
Definition: rah - Copie.hpp:1569
I iter_
Definition: rah - Copie.hpp:426
I end()
Definition: rah - Copie.hpp:88
T * type
Definition: rah - Copie.hpp:147
auto equal_range(V &&value, P &&pred, std ::enable_if_t<!is_range< V >::value, int >=0)
Returns a range containing all elements equivalent to value in the range.
Definition: rah - Copie.hpp:1365
bool equal(stride_iterator other) const
Definition: rah - Copie.hpp:904
auto distance_to(ints_iterator other) const
Definition: rah - Copie.hpp:565
void decrement()
Definition: rah - Copie.hpp:617
Definition: rah - Copie.hpp:881
auto dereference() const -> decltype(*iter_)
Definition: rah - Copie.hpp:903
zip_iterator(IterTuple const &iters)
Definition: rah - Copie.hpp:1028
range_begin_type_t< R > iter_
Definition: rah - Copie.hpp:1049
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 - Copie.hpp:772
optional(T const &other)
Definition: rah - Copie.hpp:356
auto distance_to(stride_iterator other) const
Definition: rah - Copie.hpp:905
auto map_value()
Given a range of std::pair-std::tuple, create a view consisting of just the first element of the pair...
Definition: rah - Copie.hpp:1253
typename pointer_type< R >::type pointer
Definition: rah - Copie.hpp:153
I begin(iterator_range< I > const &r)
Get the begin iterator of the range.
Definition: rah - Copie.hpp:102
void advance(intptr_t value)
Definition: rah - Copie.hpp:616
auto binary_search(V &&value)
Checks if an element equivalent to value appears within the range.
Definition: rah - Copie.hpp:1384
bool equal(take_iterator r) const
Definition: rah - Copie.hpp:437
Definition: rah - Copie.hpp:607
R range_
Definition: rah - Copie.hpp:721
bool equal(repeat_iterator) const
Definition: rah - Copie.hpp:619
size_t step_
Definition: rah - Copie.hpp:885
auto size()
Get the size of range.
Definition: rah - Copie.hpp:1723
~optional()
Definition: rah - Copie.hpp:373
Definition: rah - Copie.hpp:1755
R reference
Definition: rah - Copie.hpp:184
size_t step_
Definition: rah - Copie.hpp:1052
auto dereference() const -> decltype(*iter_)
Definition: rah - Copie.hpp:472
void advance(intptr_t value)
Definition: rah - Copie.hpp:588
auto operator=(V &&value) const
Definition: rah - Copie.hpp:197
auto dereference() const -> decltype(*std ::get< 0 >(iter_))
Definition: rah - Copie.hpp:1182
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 - Copie.hpp:161
bool equal(counted_iterator r) const
Definition: rah - Copie.hpp:473
I end(iterator_range< I > const &r)
Get the "past the" end iterator of the range.
Definition: rah - Copie.hpp:104
T const & get() const
Definition: rah - Copie.hpp:388
void next_valid()
Definition: rah - Copie.hpp:661
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
Definition: rah - Copie.hpp:768
void advance(intptr_t value)
Definition: rah - Copie.hpp:902
void increment()
Definition: rah - Copie.hpp:468
auto join()
Given a range of ranges, join them into a flattened sequence of elements.
Definition: rah - Copie.hpp:711
auto make_pipeable(MakeRange &&make_range)
Call to create a "pipeable" function (UFCS style in c++)
Definition: rah - Copie.hpp:115
bool end_
Definition: rah - Copie.hpp:507
std ::remove_reference_t< R > value_type
Definition: rah - Copie.hpp:181
auto operator-(intptr_t increment)
Definition: rah - Copie.hpp:247
auto dereference() const
Definition: rah - Copie.hpp:1032
back_insert_iterator(C &container)
Definition: rah - Copie.hpp:269
bool operator>=(I other) const
Definition: rah - Copie.hpp:258
bool operator!=(I other) const
Definition: rah - Copie.hpp:193
auto dereference() const
Definition: rah - Copie.hpp:591
decltype(begin(fake< T >())) range_begin_type_t
Definition: rah - Copie.hpp:57
size_t count_
Definition: rah - Copie.hpp:463
auto stride(size_t step)
Create a view consisting of every Nth element, starting with the first.
Definition: rah - Copie.hpp:917
std ::forward_iterator_tag iterator_category
Definition: rah - Copie.hpp:180
I iter_
Definition: rah - Copie.hpp:506
cycle_iterator(U &&range, Iterator iter)
Definition: rah - Copie.hpp:728
Definition: rah - Copie.hpp:456
bool operator>(I other) const
Definition: rah - Copie.hpp:257
range_begin_type_t< R > iter_
Definition: rah - Copie.hpp:1095
Definition: rah - Copie.hpp:297
details::optional< SubRange > subRange_
Definition: rah - Copie.hpp:641
bool equal(join_iterator other) const
Definition: rah - Copie.hpp:682
Inerit to make an iterator.
Definition: rah - Copie.hpp:128
auto & operator-=(intptr_t increment)
Definition: rah - Copie.hpp:241
bool operator!=(I other) const
Definition: rah - Copie.hpp:173
auto operator|(R &&range, pipeable< MakeRange > const &adapter) -> decltype(adapter.func(std ::forward< R >(range)))
Definition: rah - Copie.hpp:121
Iterator beginIter_
Definition: rah - Copie.hpp:723
auto operator->() const
Definition: rah - Copie.hpp:172
stream_inserter_iterator(S &stream)
Definition: rah - Copie.hpp:1758
S * stream_
Definition: rah - Copie.hpp:1757
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 - Copie.hpp:1966
range_begin_type_t< R > iter_
Definition: rah - Copie.hpp:883
auto equal(R1 &&range2)
Determines if two sets of elements are the same.
Definition: rah - Copie.hpp:1746
optional & operator=(T &&other)
Definition: rah - Copie.hpp:367
range_begin_type_t< R > iter2_
Definition: rah - Copie.hpp:1050
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 - Copie.hpp:469
auto dereference() const
Definition: rah - Copie.hpp:566
auto chunk(size_t step)
Create a view where each element is a range of N elements of the input range.
Definition: rah - Copie.hpp:1084
Apply the '==' operator on two values of any type.
Definition: rah - Copie.hpp:1931
T & fake()
Used in decltype to get an instance of a type.
Definition: rah - Copie.hpp:54
Iterator1 rangeIter_
Definition: rah - Copie.hpp:635
auto dereference() const
Definition: rah - Copie.hpp:1070
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 - Copie.hpp:1054
void increment()
Definition: rah - Copie.hpp:1063
auto stable_partition(P &&pred)
Definition: rah - Copie.hpp:1833
auto all_of(P &&pred)
Checks if unary predicate pred returns true for all elements in the range.
Definition: rah - Copie.hpp:1466
value_type * pointer
Definition: rah - Copie.hpp:183
Definition: rah - Copie.hpp:1092
void put(V &&value) const
Definition: rah - Copie.hpp:270
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 - Copie.hpp:1127
auto decrement()
Definition: rah - Copie.hpp:896
take_iterator(I iter, size_t count)
Definition: rah - Copie.hpp:430
auto operator-(I other) const
Definition: rah - Copie.hpp:254
void next_value()
Definition: rah - Copie.hpp:1110
auto empty()
Check if the range if empty.
Definition: rah - Copie.hpp:1322
void decrement()
Definition: rah - Copie.hpp:434
Func func
Definition: rah - Copie.hpp:111
Definition: rah - Copie.hpp:719
auto remove_if(P &&pred)
Keep only elements for which pred(elt) is false .
Definition: rah - Copie.hpp:2035
auto sort(P &&pred={})
Sort a range in place, using the given predicate.
Definition: rah - Copie.hpp:2061
auto copy(R2 &&out)
Copy in range into an other.
Definition: rah - Copie.hpp:1643
bool operator==(I other) const
Definition: rah - Copie.hpp:174
void increment()
Definition: rah - Copie.hpp:774
IterPair end_
Definition: rah - Copie.hpp:1161
intptr_t difference_type
Definition: rah - Copie.hpp:182
bool equal(cycle_iterator) const
Definition: rah - Copie.hpp:743
stride_iterator(range_begin_type_t< R > const &iter, range_end_type_t< R > const &end, size_t step)
Definition: rah - Copie.hpp:887
details::optional< F > func_
Definition: rah - Copie.hpp:1097
V const & dereference() const
Definition: rah - Copie.hpp:618
Definition: rah - Copie.hpp:1020
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 - Copie.hpp:1031
Reference const * operator->() const
Definition: rah - Copie.hpp:139
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
Allow to call a custom function when called whith the 'pipe' syntax on a range.
Definition: rah - Copie.hpp:109
I begin()
Definition: rah - Copie.hpp:86
bool equal(ints_iterator other) const
Definition: rah - Copie.hpp:567
range_begin_type_t< decltype(*fake< Iterator1 >())> Iterator2
Definition: rah - Copie.hpp:634
auto find_if(P &&pred)
Finds the first element satisfying specific criteria.
Definition: rah - Copie.hpp:1605
void increment()
Definition: rah - Copie.hpp:512
T & get()
Definition: rah - Copie.hpp:386
auto find_if_not(P &&pred)
Finds the first element not satisfying specific criteria.
Definition: rah - Copie.hpp:1622
Iterator endIter_
Definition: rah - Copie.hpp:724
Iterator iter_
Definition: rah - Copie.hpp:725
#define RAH_NAMESPACE
Definition: rah - Copie.hpp:39
Reference m_ref
Definition: rah - Copie.hpp:138
auto cycle()
Returns an infinite range that endlessly repeats the source range.
Definition: rah - Copie.hpp:759
auto slice(intptr_t begin, intptr_t end)
Create a view that is a sub-range of a range.
Definition: rah - Copie.hpp:873
void reset()
Definition: rah - Copie.hpp:377
auto distance_to(take_iterator r) const
Definition: rah - Copie.hpp:435
range_end_type_t< R > end_
Definition: rah - Copie.hpp:1096
auto map_key()
Given a range of std::pair-std::tuple, create a view consisting of just the second element of the pai...
Definition: rah - Copie.hpp:1268
Iterator2 subRangeIter
Definition: rah - Copie.hpp:638
decltype(*begin(fake< T >())) range_ref_type_t
Definition: rah - Copie.hpp:63
rah ::details::optional< Reference > type
Definition: rah.hpp:248
bool has_value() const
Definition: rah - Copie.hpp:375
void increment()
Definition: rah - Copie.hpp:587
Definition: rah - Copie.hpp:420
auto & operator+=(intptr_t increment)
Definition: rah - Copie.hpp:228
T const * operator->() const
Definition: rah - Copie.hpp:393
auto fill(V &&value)
Assigns the given value to the elements in the range [first, last)
Definition: rah - Copie.hpp:2106
void put(V &&value) const
Definition: rah - Copie.hpp:1759
void increment()
Definition: rah - Copie.hpp:736
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
range_end_type_t< R > end_
Definition: rah - Copie.hpp:884
std ::remove_reference_t< R > value_type
Definition: rah - Copie.hpp:151
auto to_container()
Return a container of type C, filled with the content of range.
Definition: rah - Copie.hpp:1559
auto partition(P &&pred)
Definition: rah - Copie.hpp:1811
Definition: rah - Copie.hpp:579
bool operator<=(I other) const
Definition: rah - Copie.hpp:256
auto & operator--()
Definition: rah - Copie.hpp:213
C * container_
Definition: rah - Copie.hpp:268
bool operator<(I other) const
Definition: rah - Copie.hpp:255
std ::forward_iterator_tag iterator_category
Definition: rah - Copie.hpp:150
range_begin_type_t< R > begin_
Definition: rah - Copie.hpp:1094
auto shuffle(URBG &&g)
Reorders the elements in the given range such that each possible permutation of those elements has eq...
Definition: rah - Copie.hpp:2086
I begin_iter
Definition: rah - Copie.hpp:82
size_t count_
Definition: rah - Copie.hpp:427
void advance(intptr_t off)
Definition: rah - Copie.hpp:433
auto distance_to(unbounded_iterator r) const
Definition: rah - Copie.hpp:516
Definition: rah - Copie.hpp:266
range_begin_type_t< R > Iterator1
Definition: rah - Copie.hpp:633
join_iterator(U &&range, Iterator1 rangeIter)
Definition: rah - Copie.hpp:655
range_begin_type_t< R > Iterator
Definition: rah - Copie.hpp:722
auto find(V &&value)
Finds the first element equal to value.
Definition: rah - Copie.hpp:1588
iota_iterator(T val, T step)
Definition: rah - Copie.hpp:585
void decrement()
Definition: rah - Copie.hpp:470
size_t range_index_
Definition: rah - Copie.hpp:1162
bool equal(zip_iterator other) const
Definition: rah - Copie.hpp:1034
void increment()
Definition: rah - Copie.hpp:562
Iterator2 subRangeEnd
Definition: rah - Copie.hpp:639
bool equal(iota_iterator other) const
Definition: rah - Copie.hpp:592
R range_
Definition: rah - Copie.hpp:632
bool operator()(A &&a, B &&b)
Definition: rah - Copie.hpp:1933
void advance(intptr_t off)
Definition: rah - Copie.hpp:514
I iter_
Definition: rah - Copie.hpp:462
auto erase(R &&range)
Erase a sub-range of a given container.
Definition: rah - Copie.hpp:1855
auto increment()
Definition: rah - Copie.hpp:890
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