Add a gather overload that infer element type

This commit is contained in:
Maxime Coste 2019-06-10 21:54:53 +10:00
parent 09e1ec97a9
commit d2dac558e7

View File

@ -53,7 +53,7 @@ template<typename Range>
using IteratorOf = decltype(std::begin(std::declval<Range>()));
template<typename Range>
using ValueOf = typename Range::value_type;
using ValueOf = decltype(*std::declval<IteratorOf<Range>>());
template<typename Range>
struct SkipView
@ -450,6 +450,16 @@ auto gather()
});
}
template<template <typename Element> class Container>
auto gather()
{
return make_view_factory([](auto&& range) {
using std::begin; using std::end;
using ValueType = std::remove_cv_t<std::remove_reference_t<decltype(*begin(range))>>;
return Container<ValueType>(begin(range), end(range));
});
}
template<typename ExceptionType, size_t... Indexes>
auto elements(bool exact_size = false)
{