Answers for "c++ move semantics for `this`"

C++
0

c++ move semantics for `this`

struct S
{
    std::vector<int> data;
    S doStuff() &&
    {
        std::cout << "rvalue\n";
        return {std::move(data)};
    }

    S doStuff() const&
    {
        std::cout << "const lvalue\n";
        return {data};
    } 
};
Posted by: Guest on May-09-2022

Browse Popular Code Answers by Language