[cfe-commits] [PATCH][MS][Review request] - Microsoft missing typename

Francois Pichet pichet2000 at gmail.com
Mon Nov 7 03:32:08 PST 2011


Hi,

This is my solution to the problem of missing typename in MSVC headers.
This patch resolves all the cases of missing typename in MSVC 2008
standard c++ headers and in MFC code.


This deals with 2 situations:

1. T::a where T is a TemplateTypeParmType.
In this case we depend on late template parsing to subtitute 'T' with
the actual type and then perform a name lookup to check if 'a' is a
type.


 2. ClassName<T>::a
In this case, we'll perform a name lookup in the class template
'ClassName' to check if 'a' ia a type in the pattern.


Example:

class C {
 public:
  typedef int type_1;
};

template <class T>
class D {
 public:
  typedef T type_2;
};

template <class T>
void f() {
   T::type_1 var1;         // case 1.
   D<T>::type_2 var2;   // case 2.

}
int main() {
   f<C>();
}

I admit this is a hack, that's why I am asking for review.
But given the way clang and MSVC differ in handling template code, I
think this is the best we can do.



More information about the cfe-commits mailing list