その関数から出てくる文字列が実際にメンバーvarに移動されるかどうかを誰かが確認できますか?
class Foo {
private:
const std::string m_complex_str;
std::string create_complex_str() {
return std::string("some huge string");
}
public:
Foo() : m_complex_str(std::move(create_complex_str())) { }
};
これは正しい方法ですか?
たぶん、ほとんどのコンパイラは、move関数なしでこれを実行しますか?