25#ifndef ENUMERATECONTRIB_H
26#define ENUMERATECONTRIB_H
42 template <std::
size_t N,
typename T, std::enable_if_t<N == 0>* =
nullptr>
44 -> std::conditional_t<std::is_reference_v<T>,
const std::size_t&,
49 template <std::
size_t N,
typename T, std::enable_if_t<N == 1>* =
nullptr>
51 -> std::conditional_t<std::is_reference_v<T>,
52 typename std::remove_reference_t<T>::value_type&,
53 typename std::remove_reference_t<T>::value_type> {
60 template <
typename Iterator>
63 = std::remove_reference_t<decltype(*std::declval<Iterator&>())>;
69 template <
typename Range,
typename =
void>
86 template <
typename Range>
102 template <
typename Range>
108 , begin_(this->range_begin(), 0)
109 , end_(this->range_end(), 0) {}
117 : pair_{index, iter} {}
133 return other.pair_.iter == pair_.
iter;
137 return not (other == *
this);
152# if defined(__clang__)
154# pragma clang diagnostic push
155# pragma clang diagnostic ignored "-Wmismatched-tags"
158struct tuple_size<
kblib::detail_cry::value_index_pair<T>> {
159 static constexpr std::size_t value = 2;
163struct tuple_element<0,
kblib::detail_cry::value_index_pair<T>> {
164 using type =
const std::size_t;
168struct tuple_element<1,
kblib::detail_cry::value_index_pair<T>> {
169 using type = std::remove_reference_t<decltype(*std::declval<T&>())>;
172# if defined(__clang__)
173# pragma clang diagnostic pop
185template <
typename Range>
auto get(T &&t) -> std::conditional_t< std::is_reference_v< T >, const std::size_t &, const std::size_t >
The main namespace in which all entities from kblib are defined.
typename std::enable_if< B, T >::type enable_if_t
auto cry_enumerate(Range &&range) -> auto
constexpr auto range(Value min, Value max, Delta step=0) -> range_t< Value, Delta >
Constructs a range from beginning, end, and step amount. The range is half-open, that is min is in th...
constexpr auto copy(InputIt first, EndIt last, OutputIt out) -> OutputIt
Copies all elements of [first, last) to out. It also allows for a sentinel end iterator.
value_and_index_base(Range &range)
auto range_begin() -> iterator_type
auto range_end() -> iterator_type
decltype(std::begin(std::declval< Range & >())) iterator_type
decltype(std::begin(std::declval< Range & >())) iterator_type
iterator_type range_begin_
auto range_end() -> iterator_type
value_and_index_base(Range &range)
auto range_begin() -> iterator_type
iterator(iterator_type iter, std::size_t index=0)
auto operator==(const iterator &other) const -> bool
auto operator++() -> iterator &
auto operator!=(const iterator &other) const -> bool
auto operator*() -> value_index_pair< iterator_type > &
auto operator++(int) -> iterator
typename value_and_index_base< Range >::iterator_type iterator_type
value_and_index_impl(Range &range)
std::remove_reference_t< decltype(*std::declval< Iterator & >())> value_type
std::remove_reference_t< decltype(*std::declval< T & >())> type
Provides macros and basic templates used by the rest of kblib.