I am learning c++ via the book from his creator, I understood that rValue is basically what can't be defined via it's address & you want to move it instead of copy.
Later in this book Stroustrup give an example of a Points struct
struct Point{
int x,y;
}
struct Points{
vector<Point> elem;
Points(Point p0){elem.push_back(p0)};
...
}
Point x2{ {100,200} }
So my question is basically why in the constructor it does not use an rValue to move the sent value ?
Maybe like:
struct Points{
vector<Point> elem;
Points(Point&& p0){elem.push_back(p0)};
...
}
Is it more proper / less clear to do it?
regards
Point
seems reasonable to me.p0
in your second example is an lvalue which means thatelem.push_back(p0)
makes a copy of it. If the book is any good at all it will explain that.Point
being a really simple type made only of fundamental members, it does not matter.