【发布时间】:2014-04-07 18:01:50
【问题描述】:
我更喜欢在单独的文件中编写类和函数模板的定义,该文件自动包含在“public”标题之后。但是,我遇到了一个有趣的案例,我似乎无法做到这一点。
template <typename T>
class Outer
{
public:
template <typename U>
class Inner
{
friend bool operator ==(const Inner& lhs, const Inner& rhs);
};
};
using Type = Outer<int>::Inner<short>;
int main()
{
Type a;
Type b;
a == b;
}
是否可以单独编写适用于任何T 和U 的operator== 的定义?
【问题讨论】:
标签: c++ templates c++11 operator-overloading