【发布时间】:2015-07-31 07:28:50
【问题描述】:
我正在编写一个类,它将为其构造函数之一采用特殊类型,该类型可以是任何符合我要求的类型。我遇到了这个模板化构造函数导致我的复制和移动构造函数是非法重载的问题!
我的班级是这样布置的:
template<typename ... Types>
class myclass{
public:
myclass(const myclass &other){/* copy constructor */}
myclass(myclass &&other){/* move constructor */}
template<typename Special>
myclass(Special &&arg){/* stops copy/move implementations */}
}
我怎样才能绕过这个限制?
【问题讨论】:
-
我猜你的意思是
myclass(Special &&arg)对于非 const 左值参数比复制构造函数更受欢迎? -
@PiotrSkotnicki 是的,我愿意
标签: c++ templates c++14 forwarding-reference