c++ r-value references ed

r-value ref parameters are l-values! (they have a name)
void g(const X &x);
void g(X && x);
void f(X && x) {
    g(x); // will call g(const X &x)
}

fix: std::move()
void f(X && x) {
    g(std::move(x)); // will call g(X && x)
}

don't return via std::move()
(return optimization might happen!)

X f() {
    X x;
    return std::move(x); !!! NOPE, since x might already be at the location of the return target
}

Categories: c++, Programmieren