I have read many articles about move constructor (even on stack) but i didn't find anywhere an exact explanation about how this works (how is transfer pointer to a temporary object and saved if this temporary variable and its address will be destroy when meet ")" ).
Here is a simple example
#include <iostream>
#include <vector>
using namespace std;
class boVector {
private:
int size;
public:
boVector() {};
boVector(const boVector& rhs) { cout << "copy Ctor." << endl; }
boVector(boVector&& rhs) { cout << "move Ctor." << endl; }
};
void foo(boVector v) {}
boVector createBoVector() { return boVector(); }
int main()
{
//copy
boVector reausable = createBoVector();
foo(reausable);
//move
foo(std::move(createBoVector()));
return 0;
}
All say that a move Ctor is a shallow copy copy or just a pointer assignment. But how can i initiate my object with a pointer to a temporary object (when this object will be destroy my object will point to an unknown address and this is not valid from my point of view).
Is not right to initiate a variable with a pointer address that will no longer exist after he meet ")".
Please if can somebody explain me how looks this temporary variable in memory and how is possible to assigned the address of temporary object to my current one and this operation to be a valid one.