Why is derived class move constructible when base class isn’t?

Because:

A defaulted move constructor that is defined as deleted is ignored by overload resolution.

([class.copy]/11)

Bar‘s move constructor is explicitly deleted, so Bar cannot be moved. But Foo<Bar>‘s move constructor is implicitly deleted after being implicitly declared as defaulted, due to the fact that the Bar member cannot be moved. Therefore Foo<Bar> can be moved using its copy constructor.

Edit: I also forgot to mention the important fact that an inheriting constructor declaration such as using Base::Base does not inherit default, copy, or move constructors, so that’s why Foo<Bar> doesn’t have an explicitly deleted move constructor inherited from Bar.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)