Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ move semantics for `this`

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

    S doStuff() const&
    {
        std::cout << "const lvalue
";
        return {data};
    } 
};
 
PREVIOUS NEXT
Tagged: #move #semantics
ADD COMMENT
Topic
Name
3+9 =