Вот источник:
#include <type_traits>
#include <utility>
class A {
protected:
//public: // if public, it's fine. (?)
A()noexcept{}
A(A&&) noexcept{}
};
class B : public A {
static_assert(std::is_nothrow_constructible<A>::value,"err1"); // ! err1
static_assert(std::is_nothrow_move_constructible<A>::value,"err2"); // ! err2
public:
B()noexcept(std::is_nothrow_constructible<A>::value):A(){}
B(B&& o)noexcept(std::is_nothrow_move_constructible<A>::value):A(std::move(o)){}
};
int main(){
static_assert(std::is_nothrow_constructible<B>::value,"err3"); // ! err3
static_assert(std::is_nothrow_move_constructible<B>::value,"err4"); // ! err4
return 0;
}
Компиляция завершается с ошибками err1, err2, err3 и err4.Но если бы я обнародовал конструкторы класса А. это работает.Почему?
(Clang 6.0,7.0; gcc 8.x; ...)