Given the following class template:
template<typename T>
struct Outer
{
struct Inner;
auto f(Inner) -> void;
};
we define Inner
separately for each specialization of Outer
:
template<>
struct Outer<int>::Inner {};
template<>
struct Outer<double>::Inner {};
and then define the member function f
once for all specializations of Outer
:
auto Outer<T>::f(Inner) -> void
{
}
but Clang (9.0.0) complains:
error: variable has incomplete type 'Outer::Inner'
auto Outer<T>::f(Inner) -> void
^
We can evade the compiler error by also providing a definition of Inner
for all other specializations of Outer
:
template<typename T>
struct Outer<T>::Inner {};
or by defining f
separately for each specialization:
template<>
auto Outer<int>::f(Inner) -> void
{
}
template<>
auto Outer<double>::f(Inner) -> void
{
}
Both GCC and MSVC accept the initial code, which begs the question; is this a Clang bug or is it the only conformant implementation out of the three?