3#include "../utility/empty_base.h"
16 template<
typename T,
typename =
void>
20 struct is_iterable<
T, std::
void_t<decltype(std::begin(std::declval<T&>())), decltype(std::end(std::declval<T&>()))>> : std::true_type {};
26 template<
typename T,
typename =
void>
36 template<
typename K,
typename V>
40 template<
typename A,
typename B>
41 ipair_value(A&& key, B&& value)
noexcept(std::is_nothrow_constructible_v<K, A> && std::is_nothrow_constructible_v<V, B>) :
42 first(std::forward<A>(key)),
43 second(std::forward<B>(value)) {}
59 template<
typename K,
typename I>
63 using V =
decltype(*std::declval<I&>());
73 ipair_iterator(I&& iterator)
noexcept(std::is_nothrow_default_constructible_v<K> && std::is_nothrow_move_constructible_v<I>) :
74 m_Iterator(std::move(iterator)),
94 template<
typename IT = I>
95 typename std::enable_if_t<std::is_copy_constructible_v<ipair_iterator<K, IT>>,
ipair_iterator>
96 operator++(
int)
noexcept(std::is_nothrow_copy_constructible_v<ipair_iterator> &&
noexcept(++std::declval<K&>()) &&
noexcept(++std::declval<I&>()))
104 template<
typename IT = I>
105 typename std::enable_if_t<detail::is_decrementable_v<IT>,
ipair_iterator&>
106 operator--() noexcept(noexcept(--std::declval<K&>()) && noexcept(--std::declval<I&>()))
113 template<
typename IT = I>
115 operator--(
int)
noexcept(std::is_nothrow_copy_constructible_v<ipair_iterator> &&
noexcept(--std::declval<K&>()) &&
noexcept(--std::declval<I&>()))
125 return m_Iterator == b.m_Iterator;
130 return m_Iterator != b.m_Iterator;
138 template<
typename K,
typename C>
144 using begin_type =
decltype(std::declval<C&>().begin());
145 using begin_const_type =
decltype(std::declval<const C&>().begin());
154 m_Container(std::forward<V>(container)) {}
156 template<
typename V = C>
157 typename std::enable_if_t<detail::is_iterable_v<std::decay_t<V>>,
iterator>
158 begin() noexcept(noexcept(std::declval<V&>().
begin()) && noexcept(
iterator(std::declval<begin_type>())))
160 return iterator(m_Container.begin());
163 template<
typename V = C>
164 typename std::enable_if_t<detail::is_iterable_v<std::decay_t<V>>,
iterator>
165 end() noexcept(noexcept(std::declval<V&>().
end()) && noexcept(
iterator(std::declval<begin_type>())))
170 template<
typename V = C>
171 typename std::enable_if_t<detail::is_iterable_v<std::add_const_t<std::decay_t<V>>>,
const_iterator>
177 template<
typename V = C>
178 typename std::enable_if_t<detail::is_iterable_v<std::add_const_t<std::decay_t<V>>>,
const_iterator>
179 end() const noexcept(noexcept(std::declval<const V&>().
end()) && noexcept(
const_iterator(std::declval<begin_type>())))
188 template<
typename K,
typename C>
197 return ipair<size_t, C>(std::forward<C>(container));
Wraps an iterable object for use with indexed iterators.
Definition ipair.h:140
std::enable_if_t< detail::is_iterable_v< std::decay_t< V > >, iterator > end() noexcept(noexcept(std::declval< V & >().end()) &&noexcept(iterator(std::declval< begin_type >())))
Definition ipair.h:165
std::enable_if_t< detail::is_iterable_v< std::add_const_t< std::decay_t< V > > >, const_iterator > begin() const noexcept(noexcept(std::declval< const V & >().begin()) &&noexcept(const_iterator(std::declval< begin_type >())))
Definition ipair.h:172
ipair_iterable(V &&container) noexcept(std::is_nothrow_constructible_v< C, V >)
Definition ipair.h:153
ipair_iterator< K, begin_const_type > const_iterator
Definition ipair.h:149
std::enable_if_t< detail::is_iterable_v< std::decay_t< V > >, iterator > begin() noexcept(noexcept(std::declval< V & >().begin()) &&noexcept(iterator(std::declval< begin_type >())))
Definition ipair.h:158
ipair_iterator< K, begin_type > iterator
Definition ipair.h:148
std::enable_if_t< detail::is_iterable_v< std::add_const_t< std::decay_t< V > > >, const_iterator > end() const noexcept(noexcept(std::declval< const V & >().end()) &&noexcept(const_iterator(std::declval< begin_type >())))
Definition ipair.h:179
Wraps an iterator to return an index along with the value.
Definition ipair.h:61
ipair_iterator(I &&iterator) noexcept(std::is_nothrow_default_constructible_v< K > &&std::is_nothrow_move_constructible_v< I >)
Definition ipair.h:73
std::enable_if_t< std::is_copy_constructible_v< ipair_iterator< K, IT > >, ipair_iterator > operator++(int) noexcept(std::is_nothrow_copy_constructible_v< ipair_iterator > &&noexcept(++std::declval< K & >()) &&noexcept(++std::declval< I & >()))
Definition ipair.h:96
bool operator==(const ipair_iterator &b) const noexcept(noexcept(std::declval< const I & >()==std::declval< const I & >()))
Definition ipair.h:123
std::enable_if_t< std::is_copy_constructible_v< ipair_iterator< K, IT > > &&detail::is_decrementable_v< IT >, ipair_iterator > operator--(int) noexcept(std::is_nothrow_copy_constructible_v< ipair_iterator > &&noexcept(--std::declval< K & >()) &&noexcept(--std::declval< I & >()))
Definition ipair.h:115
value_type operator->() const noexcept(std::is_nothrow_constructible_v< value_type, K, I > &&noexcept(*std::declval< I & >()))
Definition ipair.h:82
ipair_iterator & operator++() noexcept(noexcept(++std::declval< K & >()) &&noexcept(++std::declval< I & >()))
Definition ipair.h:87
bool operator!=(const ipair_iterator &b) const noexcept(noexcept(std::declval< const I & >() !=std::declval< const I & >()))
Definition ipair.h:128
ipair_value< K, V > value_type
Definition ipair.h:68
std::enable_if_t< detail::is_decrementable_v< IT >, ipair_iterator & > operator--() noexcept(noexcept(--std::declval< K & >()) &&noexcept(--std::declval< I & >()))
Definition ipair.h:106
value_type operator*() const noexcept(std::is_nothrow_constructible_v< value_type, K, I > &&noexcept(*std::declval< I & >()))
Definition ipair.h:77
Pair of an index and value from an iterator.
Definition ipair.h:38
KTL_EMPTY_BASE K first
Definition ipair.h:55
ipair_value(A &&key, B &&value) noexcept(std::is_nothrow_constructible_v< K, A > &&std::is_nothrow_constructible_v< V, B >)
Definition ipair.h:41
const ipair_value * operator->() const noexcept
Definition ipair.h:50
KTL_EMPTY_BASE V second
Definition ipair.h:56
ipair_value * operator->() noexcept
Definition ipair.h:45
#define KTL_EMPTY_BASE
Definition empty_base.h:6
constexpr bool has_no_value_type_v
Definition meta.h:17
constexpr bool is_decrementable_v
Definition ipair.h:33
constexpr bool is_iterable_v
Definition ipair.h:23
Definition cascading.h:16
ipair_iterable< K, C > ipair(C &&container) noexcept(std::is_nothrow_constructible_v< ipair_iterable< K, C >, C >)
Wraps an iterable object to return an index along with the value.
Definition ipair.h:189