大家讨论一下,VC2005不支持那些C++标准语言特性!
zogy 2008-03-27 05:58:11 实际使用中,发现了两个,如下:
1、不支持成员模板的默认非类型参数:
template< int m = 0 > class Caa
{
public:
template< typename T = int > class Cbb {};
template< int n = 0 > class Ccc {};
};
Caa<>::Cbb<> g1; // ok
Caa<>::Ccc<> g2; // error
2、不支持两阶段查找(tow-phase lookup)
void Test(void)
{
cout << "1" << endl;
}
template< typename T > struct Caa
{
void Test(void)
{
cout << "2" << endl;
}
};
template< typename T > struct Cbb : public Caa< T >
{
int MemTest()
{
Test(); /* 根据标准,非依赖非受限的名称将马上查找;
此时依赖基类中的成员函数不确定;所以只能
找到全局的函数;GCC执行的是全局的函数;
可VC2005执行的却是是基类中的成员函数 */
this->Test(); /* 受限并依赖的名称只有到实例化时才查找;
此时会找到依赖基类中的成员函数。*/
return 0;
}
};
int g = Cbb< int >().MemTest();