我想继承一个模板类,并使用“使用”来继承它的构造函数。但是当我调用移动构造函数时,“没有匹配的构造函数”失败
#include <iostream>
template <typename ARG>
class TBase {
public:
TBase() {}
TBase(TBase<ARG>&& t) {}
private:
ARG arg;
};
class Int : public TBase<int> {
public:
using TBase<int>::TBase;
};
int main() {
TBase<int> t1;
Int t2(std::move(t1));
return 0;
}
构建结果
In function 'int main()':
20:23: error: no matching function for call to 'Int::Int(std::remove_reference<TBase<int>&>::type)'
20:23: note: candidates are:
13:7: note: Int::Int()
13:7: note: candidate expects 0 arguments, 1 provided
13:7: note: Int::Int(Int&&)
13:7: note: no known conversion for argument 1 from 'std::remove_reference<TBase<int>&>::type {aka TBase<int>}' to 'Int&&'