I have this C++ test code snippet,
#include <vector>
class A {
std::vector<int> x;
public:
A(std::vector<int>&& _x) : x(_x) {}
};
class B {
A a;
public:
B(std::vector<int>&& _x) : a(/*move(*/_x/*)*/) {}
};
I'm passing _x
to B as rvalue reference, but it's getting converted to lvalue when passed into A
's constructor and I have to use std::move()
to make it work. My question is why _x is lvalue and not an rvalue reference in a()
?