Open huixie90 opened 3 years ago
This has the effect, that you can't combine g++-12
views with range-v3 views any more.
But this has more implications to the underlying range-v3 implementation, as some views expect default_initializable
.
But this has more implications to the underlying range-v3 implementation, as some views expect
default_initializable
.
can you an example or two? also it should be ok for a view to be default_initializable
(most are I suppose). it just shouldn't be required for all views.
std::views::ref_view
does not have a default constructor.
That means the basic building block std::views::all
isn't combinable with any range-v3 view.
#include <ranges>
#include <vector>
#include <range/v3/range/concepts.hpp>
namespace ranges
{
//!\brief std::ranges::views are valid range-v3 views
template<::std::derived_from<::std::ranges::view_base> T>
inline constexpr bool enable_view<T> = true;
}
namespace std::ranges
{
//!\brief range-v3 views are valid std::ranges::views
template<class T>
requires ::std::derived_from<T, ::ranges::view_base>
inline constexpr bool enable_view<T> = true;
}
int main()
{
std::vector<int> numbers{};
auto view = std::views::all(numbers);
static_assert(std::ranges::view<decltype(view)>);
// ranges::cpp20::view<decltype(view)> requires
/*1.)*/ static_assert(ranges::range<decltype(view)>); // true
/*2.)*/ static_assert(ranges::semiregular<decltype(view)>); // false
/*3.)*/ static_assert(ranges::enable_view<decltype(view)>); // true
static_assert(ranges::cpp20::view<decltype(view)>); // false
return 0;
}
https://godbolt.org/z/58o4sc4TP
(Independent of the current ICE)
But I guess dropping semiregular
in favour of copyable
would be a good first step for range-v3, as most views of range-v3 should work with non-default initializable views.
https://github.com/ericniebler/range-v3/pull/1652 did a similar thing for weakly_incrementable
(relaxing it from semiregular
to copyable
).
I guess dropping semiregular in favour of copyable would be a good first step
Putting the relevant proposals here for reference:
These are both in C++20 for good reasons. range-v3 should follow suit without beating around the bush.
I remember Eric mentioning recently that just modifying the concepts isn't enough as there is code that make assumptions as to what the concepts require.
ranges::view_
requiressemiregular
butstd::ranges::view
only requiresmovable
. std doesn't require copyable or default constructible. Is there a plan to make range-v3 consistent with std::range ?