次のスニペットは、それ以外の方法で生成されたクラスのメソッドとコンストラクターをすべて定義解除するのに正しいですか?
struct Picture {
// 'explicit': no accidental cast from string to Picture
explicit Picture(const string &filename) { /* load image from file */ }
// no accidental construction, i.e. temporaries and the like
Picture() = delete;
// no copy
Picture(const Picture&) = delete;
// no assign
Picture& operator=(const Picture&) = delete;
// no move
Picture(Picture&&) = delete;
// no move-assign
Picture& operator=(Picture&&) = delete; // return type correct?
};
これにより、すべてのデフォルトのコンパイラ実装が削除され、デストラクタだけが残りますよね? それがなければ、クラスは(ほとんど)使用できないと思いますが、削除することもできますよね?
Picture&
move-assignの戻り値の型はoperator=(Picture&&)
正しいですか? Picture&&
戻り値の型について書いた場合、違いはありますか?