diff options
| -rw-r--r-- | src/ranges.hh | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ranges.hh b/src/ranges.hh index 88f6d2ef..014dbd8b 100644 --- a/src/ranges.hh +++ b/src/ranges.hh @@ -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) { |
