特に関連して、可能であればstd::vector
型がnoexcept
移動可能であることが重要です。
= default
したがって、次のような移動コンストラクターを宣言するとき
struct Object1
{
Object1(Object1 &&other) = default;
};
std::is_nothrow_move_constructible<Object1>::value
のtrue
すべてのメンバー (ここでは 0)Object1
は notrow-move-constructible であり、ここで回答されます。
= default
しかし、次のコードのように、ムーブ コピー コンストラクターが宣言され、後で定義されている場合はどうなるでしょうか。
struct Object2
{
Object2(Object2 &&other);
};
Object2::Object2(Object2 &&other) = default;
g++ 4.9.2 ではstd::is_nothrow_move_constructible<Object2>::value
、false
宣言と定義の両方noexcept
を make itとしてマークする必要がありtrue
ます。
今、私が興味を持っているのは、実際のルールが何であるかです。特に、Effective Modern C++の Item 22 (Scott Meyers) は、私がObject2
.