Is this valid C++?
template
class any_iterator : public any_iterator
{
public:
typedef any_iterator an
To inherit from a type, that type must be complete. A little rearranging solves things:
template<class category>
class any_iterator;
template<>
class any_iterator<void>
{
public:
typedef any_iterator<void> any_iter_void;
any_iterator() { }
void foo() { }
};
template<class category>
class any_iterator : public any_iterator<void>
{
public:
typedef any_iterator<void> any_iter_void;
any_iterator() : any_iter_void() { }
};
int main()
{
any_iterator<int> a;
a.foo();
}
Token standard quotes:
C++11, §10/2:
The type denoted by a base-type-specifier shall be a class type that is not an incompletely defined class; this class is called a direct base class for the class being defined.
§9.2/2:
A class is considered a completely-defined object type (or complete type) at the closing
}
of the class-specifier.
10/2:
The type denoted by a base-type-specifier shall be a class type that is not an incompletely defined class
It is one manifestation of the bug of MSVC: its lack of two-phase name resolution.