https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123249
Bug ID: 123249
Summary: declaration of template parameter 'class V' with
different constraints
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
https://godbolt.org/z/3j8dhbcP7
#include <memory>
#include <ranges>
namespace std::ranges {
template <class T>
class any_view {
template <view V>
class view_target;
struct iterator {
template <view V>
friend class view_target;
};
struct view_wrapper {
virtual constexpr iterator begin() = 0;
};
template <view V>
struct view_target : view_wrapper {
V base_;
constexpr view_target(V base) : base_(std::move(base)) {}
virtual constexpr iterator begin() override { return {}; }
};
polymorphic<view_wrapper> base_;
public:
template <input_range Rng>
requires viewable_range<Rng>
constexpr any_view(Rng&& rng)
: base_(in_place_type<view_target<views::all_t<Rng>>>,
views::all(std::forward<Rng>(rng))) {}
};
} // namespace std::ranges
int main() {
auto l = {1, 2, 3, 4, 5};
std::ranges::any_view<int> a{l};
}
I encountered a very strange problem. Regarding the above, GCC gives:
<source>:11:15: error: declaration of template parameter 'class V' with
different constraints
11 | template <view V>
| ^~~~
<source>:8:13: note: original declaration appeared here
8 | template <view V>
| ^~~~
But the two signatures look exactly the same to me. I don't know why GCC
rejected it.