I know that, generally, we can forward-declare enums in C++11.
So, why does this:
enum kind_t { kind1, kind2 };
template <kind_t Kind> struct foo {};
template <> struct foo<kind1> {
enum named : int;
};
enum foo<kind1>::named : int {
named1 = 123,
named2 = 456,
};
fail to compile with GCC (12.1)? The error is (Godbolt):
<source>:9:6: error: cannot add an enumerator list to a template instantiation
9 | enum foo<kind1>::named : int {
| ^~~~~~~~~~
ASM generation compiler returned: 1
<source>:9:6: error: cannot add an enumerator list to a template instantiation
9 | enum foo<kind1>::named : int {
| ^~~~~~~~~~
This seems to compile fine with clang++ 14.0...
I've filed this as a GCC compiler bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116703
if you follow this link, and it's been resolved - please comment or edit this answer to explain what the resolution was.