It seems that VS 2008 handles class templates with inheritance a bit differently from the other compilers.
The following code compiles without any error on VS 2008 (with default options):
template <typename S, typename T>
class someclass : public non_existent_class
{
T operator() (S s) const {
return T(s);
}
};
Question is, why? No other compiler has been able to do this (tried GCC 4.5.0, Intel, Online Comeau, VS 2005), because of undefined identifier non_existent_class. Maybe it is something in the new C++0x standard that justifies this behavior?
This is most likely a consequence of the fact that visual studio does single phase name lookup when it’s supposed to do two phase. The non-dependent name “non_existent_class” should fail in the first phase, which happens at the point of definition whether or not the template is ever instantiated.
It’s a bug, but it’s one that is never, ever going to be fixed until MS fundamentally changes the way their compiler works wrt templates.
http://womble.decadent.org.uk/c++/template-faq.html#two-phase
http://blog.llvm.org/2009/12/dreaded-two-phase-name-lookup.html