constメンバオブジェクトとmove
struct Foo { Foo() = default; Foo(Foo const & foo) = default; Foo(Foo && foo) {} }; struct Bar { Foo const foo; Bar() = default; Bar(Bar const & other) = default; Bar(Bar && other) : foo(std::move(other.foo)) {} // foo の初期化にはコピーコンストラクタが呼ばれる };
Foo constメンバを保持するBarのムーブコンストラクタを作る場合、constメンバの扱いをどうするべきなんだろう。
std::move(other.foo)はFoo const &&のはずだから、これ自分でconst_cast