The following code compiles on VS2005 and gcc-4.3.4.
#include
#include
template
struct X { };
typedef std::pair Pr;
X var;
int main()
{
std::cout << "hello\n";
}
But it fails to compile on VS2010 with the error message:
1>d:\a\testvs10\testvs10.cpp(13): error C2440: 'specialization' : cannot convert from 'int std::_Pair_base<_Ty1,_Ty2>::* ' to 'int std::pair<_Ty1,_Ty2>::* '
1> with
1> [
1> _Ty1=int,
1> _Ty2=int
1> ]
1> Standard conversion from pointer-to-member of base to pointer-to-member of derived is not applied for template arguments
I understand that in microsoft's implementation of VS2010 Pr::first
is actually a member of _Pair_base
. However, AFAIK, it doesn't matter. &Pr::first
still must be of a type int Pr::*
. Note that the following code compiles fine:
int Pr::* x = &Pr::first;
So, is it a non-standard std::pair implementation, a compiler bug, or a non-standard code?