【发布时间】:2015-09-05 13:47:25
【问题描述】:
template <typename T>
struct id
{
typedef T type;
};
class S{
public:
template<typename T, int N>
operator typename id<T(&)[N]>::type ();
};
void f(int(&)[20]) {}
void g(S s) { cout << typeid(f(s)).name(); }
gcc 编译总是报错: 错误:从类型“S”的表达式中对类型“int (&)[20]”的引用的初始化无效
为什么会失败?
【问题讨论】:
标签: c++ c++11 type-conversion type-deduction