【发布时间】:2016-07-19 06:40:50
【问题描述】:
使用 g++ 3.4 和 4.7 我观察到以下奇怪的行为:
如果需要用户定义的转换,则函数模板不匹配,而普通函数则需要。 我在 C++98 标准中找不到相应的规则。 g++ 是否正确(如我所料)?还是bug?
template <class T>
int x(auto_ptr_ref<T> p)
{
return 1;
}
// this would match
/*
int x(auto_ptr_ref<int> p)
{
return 2;
}
*/
void dummy()
{
cout << x(auto_ptr<int>()) << endl;
}
【问题讨论】:
标签: c++ function templates implicit-conversion overload-resolution