I basically have a class that depends on a non-type template parameter. I defined a casting so an object of non-type template parameter N
can convert to another of
This is a clang bug. Here's a short reproduction:
template <int A>
struct X {
template <auto B>
X<B> foo();
};
template <int A>
template <auto B>
X<B> X<A>::foo() {
return {};
}
If auto B
is replaced by int B
, clang accepts it. gcc accepts it as-is. For clang, this is only a problem with the nested template
declarations. There's nothing about auto
as a placeholder template non-type parameter that would prevent it from being used to define something out-of-line.
While filing a new clang bug, I found 35655, with an even shorter reproduction:
template<typename>
struct S {
template<auto n>
static void f() {
+n;
}
};
which fails with:
source.cpp:5:3: error: invalid argument type 'auto' to unary expression
+n;