Reputation: 13988
The simplest snippet I managed to get to reproduce the problem is as follows:
#include <variant>
template <auto V>
using ic = std::integral_constant<decltype(V), V>;
enum { shake };
int milk(ic<shake>);
template <class...>
struct context {
template <auto V>
decltype(milk(ic<V>{})) get() {
return std::get<decltype(milk(ic<V>{}))>(value);
}
std::variant<int> value;
};
int main(){
context<int> c;
c.get<shake>();
}
There is something fishy going on here in [clang] as it suggests that:
prog.cc:13:42: error: a non-type template parameter cannot have type 'auto'
return std::get<decltype(milk(ic<V>{}))>(value);
^
prog.cc:3:16: note: template parameter is declared here
template <auto V>
^
1 error generated.
When we change the ic
to an aliased type or use the untemplated version of context
everything works as expected. So is it really clang's bug or am I missing something obvious here?
PS. In [gcc] everything works as expected...
Upvotes: 21
Views: 456