我正在尝试使用模板构造函数std::enable_if的参数类型匹配类型" MyClass" 时禁用模板类的模板构造函数,以便我可以使用我的其他构造函数,这允许我使用类初始化当前模板的类另一个
template <typename t, size_t size>
class MyClass
{
public:
MyClass() { data.fill(static_cast<T>(0)); }
template <typename... Args> // i want to disable this if Args = MyClass
MyClass(Args&&... args) : data{ std::forward<Args>(args)... } {}
template <size_t size2>
MyClass(const Myclass<t, size2>& other_sized_template) { /*do stuff*/ } // this won't work unless the template ctor above is disabled if the arguments passed are of type Myclass
private:
std::array<t, size> data;
};
Run Code Online (Sandbox Code Playgroud)