Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

041-move-support: 「基本の実装」掲載のムーブ代入演算子は参照を返していない #156

Open
hi-hori opened this issue Jul 15, 2021 · 0 comments

Comments

@hi-hori
Copy link

hi-hori commented Jul 15, 2021

    // ムーブ
    Integer( Integer && r )
        : ptr( r.ptr )
    { r.ptr = nullptr ; }
    Integer operator =( Integer && r )
    {
        delete ptr ;
        ptr = r.ptr ;
        r.ptr = nullptr ;
        return *this ;
    }

上記のコードが掲載されていますが、上記実装だと自身のコピーを返してしまいます。
正しくは Integer & operator =( Integer && r ) ではないでしょうか?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant