#include <iostream>
using namespace std;
struct foo{
    int x;
    double y;
    double z;
    foo(int x_,double y_,double z_)
    {
        x = x_;
        y = y_;
        z = z_;
    }
    foo(const foo& f){
        cout<<"foo copy for const ref called"<<endl;
        x = f.x;
        y = f.y;
        srand((unsigned ) time(nullptr));
        int z_ = rand();
        z = z_;
        cout<<f.x<<endl;
    }
    foo(foo&& f) {
        cout<<"foo copy for right ref called"<<endl;
        x = f.x;
        y = f.y;
        srand((unsigned ) time(nullptr));
        int z_ = rand();
        z = z_;
        cout<<f.x<<endl;
    }
};
int main()
{
    srand((unsigned ) time(nullptr));
    int rand_ = rand();
    foo f_(foo(rand_, 2, 3));
    cout<<f_.x<<' '<<f_.y<<' '<<f_.z<<endl;
}
I run the above code in gcc, and got the following output:
21862 2 3
I was expecting than the foo(foo&& f) will be called, but out of my expect, none of the copy constructors was called, and f_.z was set to be 3, I expect it to be a random value.
why is none of the copy constructors being called?
