std-ranges

How you create your own views that interact with existing views with operator |?

孤街醉人 提交于 2021-02-16 04:38:54
问题 Why does this code work with the #if 0 block in place, but fails with a fairly complex set of error messages if you remove it? And more importantly, how do I make it the same result as the very similar block above it? #include <ranges> #include <iterator> #include <optional> #include <string_view> #include <iostream> #include <algorithm> template <::std::ranges::view View, typename Pred> requires ::std::ranges::input_range<View> && ::std::ranges::common_range<View> && ::std::is_object_v<Pred>

How you create your own views that interact with existing views with operator |?

穿精又带淫゛_ 提交于 2021-02-16 04:36:33
问题 Why does this code work with the #if 0 block in place, but fails with a fairly complex set of error messages if you remove it? And more importantly, how do I make it the same result as the very similar block above it? #include <ranges> #include <iterator> #include <optional> #include <string_view> #include <iostream> #include <algorithm> template <::std::ranges::view View, typename Pred> requires ::std::ranges::input_range<View> && ::std::ranges::common_range<View> && ::std::is_object_v<Pred>

How you create your own views that interact with existing views with operator |?

妖精的绣舞 提交于 2021-02-16 04:35:41
问题 Why does this code work with the #if 0 block in place, but fails with a fairly complex set of error messages if you remove it? And more importantly, how do I make it the same result as the very similar block above it? #include <ranges> #include <iterator> #include <optional> #include <string_view> #include <iostream> #include <algorithm> template <::std::ranges::view View, typename Pred> requires ::std::ranges::input_range<View> && ::std::ranges::common_range<View> && ::std::is_object_v<Pred>

Use of 'auto […] 'before deduction of 'auto' with recursive, concept-based function template

荒凉一梦 提交于 2020-12-25 03:48:06
问题 I wanted to create a deep_flatten function template that would produce a range of elements that are deeply join ed. For example, if we take into account only nested std::vector s, I can have: template <typename T> struct is_vector : public std::false_type { }; template <typename T, typename A> struct is_vector<std::vector<T, A>> : public std::true_type { }; template <typename T> auto deepFlatten(const std::vector<std::vector<T>>& vec) { using namespace std::ranges; if constexpr (is_vector<T>: