Differences from Other Implementations
Microsoft Specific
Templates are not officially standardized and, as a result, different C++ compiler vendors have implemented them differently. The following list shows some differences between this version of Visual C++ and other compilers. Note that this list will change in future versions of the compiler.
-
The compiler cannot instantiate a template outside of the module in which it is defined.
-
Templates cannot be used with functions declared with __declspec (dllimport) or __declspec (dllexport).
-
All template arguments must be of an unambiguous type that exactly matches that of the template parameter list. For example:
template< class T > T check( T );
template< class S > void watch( int (*)(S) );
watch( check ); //error
The compiler should instantiate the check
templated function in the form int check( int )
, but the inference can not be followed.
-
Friend functions must be declared before they are used in a templated class. You cannot have a friend function defined within a class definition. This is because the friend function could be a templated function, which would cause an illegal nested template definition.
END Microsoft Specific