fork download
#include 
#include 

using namespace std;

struct Noisy {
        int n;
	Noisy() :n(0) { cout << "Noisy()\n"; }
	Noisy(const Noisy & o) :n(o.n) { cout << "copy Noisy\n"; }
	Noisy(Noisy&& o) :n(o.n) { cout << "move Noisy\n"; }
};

Noisy foo(bool x)
{
	Noisy a;
	a.n = 5;
	Noisy b;
	b.n = 10;

        // does this not exclude the possibility of copy elision?
	if (x) return a;
	else return b;
}

int main()
{
        // does this not move?  See output below
	Noisy n = foo(rand()%2==0);
	cout << n.n;
}
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
Noisy()
Noisy()
move Noisy
10