Joh*_*itb 11 c++ inheritance protected noexcept c++11
我们有这种情况,并想知道解决它的最佳方法
template<typename T>
struct A : T {
  A(T &&t) noexcept(noexcept(T(std::move(t))))
     :T(std::move(t))
  { }
};
遗憾的是,这无法编译,因为T的移动构造函数受到保护,我们只允许在构造函数初始化列表中调用它*this.有什么办法使这项工作或甚至有一个标准的方法呢?
您正在寻找noexcept(std::is_nothrow_move_constructible<T>::value):
 http ://en.cppreference.com/w/cpp/types/is_move_constructible