#include <vector>
#include <iostream>
#include <utility>
/**-------------------------------------------------------------*
   niepotrzebne kopiowanie                               *
 *--------------------------------------------------------------*/

// A = std::move(B);
// Now A contains the elements that were previously held by B, and B is now empty. This avoids copying: the internal representation is simply moved from B to A, so this is an O(1) solution.

using namespace std;

class Point {
    vector<double> vec_;
public:
    Point(double x, double y) {
        vec_.push_back(x);
        vec_.push_back(y);
    }
    Point(const Point& p) : vec_(p.vec_) {
        cout << "Point copy c-tor" << endl;
    }
    Point(Point&& p) {
        cout << "Point r-value copy c-tor" << endl;
        vec_ = std::move(p.vec_);
    }
    void inc_x() {
        vec_[0] += 1.0;
    }
    ~Point() { }
};

Point h(Point p) {
    //funkcja f modyfikuje i wykorzystuje p
    p.inc_x();
    return p;
}

int main() {
    Point p1(1.0, 1.0);
    h(p1);
    //p1 nie powinien być zmodyfikowany
    h(h(h(Point(2.0, 2.0))));
    return 0;
}
