`
febird
  • 浏览: 247472 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

VC++ 6.0 的函数模版解析 bug

阅读更多

struct TTT1 { int x; };
struct TTT2 { int x; };

template<class T1, class T2>
void foo(T1& t1, T2& t2)
{
 printf("111111111111\n");
}

template<class T1>
void foo(T1& t1, TTT2& t2)
{
 printf("222222222222\n");
}

void foo2()
{
 TTT1 x;
 TTT2 y;
 foo(x, y);
}

上述代码在 vc6 中编译会出错:

error C2667: 'foo' : none of 2 overload have a best conversion
error C2668: 'foo' : ambiguous call to overloaded function

在 vc2005 中,gcc 中编译都通过。本来一个好好的库,因为这个原因在 VC6 下不能用了。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics