C++0x Default Move Functions

move constructor と move assignment operator のデフォルトの書き方

class Derived : public Base {
    std::vector<int> vec;
    std::string      name;
public:
    // move constructor
    Derived(Derived&& x)
        : Base(std::forward<Base>(x)),
          vec(std::move(x.vec)),
          name(std::move(x.name))
    {}

    // move assignment operator
    Derived& operator=(Derived&& x)
    {
        Base::operator=(std::forward<Base>(x));
        vec  = std::move(x.vec);
        name = std::move(x.name);
        return *this;
    }
};


N2583 Default Move Functions

右辺値参照・ムーブセマンティクス