23 template <
typename container_type,
24 typename container_type_iter =
25 decltype(
std::begin(std::declval<container_type>())),
26 typename = decltype(
std::end(std::declval<container_type>()))>
27 constexpr
auto enumerate(container_type &&iterable) {
30 container_type_iter iter;
32 bool operator!=(
const iterator &
rhs)
const {
return iter != rhs.iter; }
41 auto operator*()
const {
return std::tie(
i, *iter); }
43 struct iterable_wrapper {
44 container_type iterable;
46 auto end() {
return iterator{0,
std::end(iterable)}; }
48 return iterable_wrapper{std::forward<container_type>(iterable)};