[ create a new paste ] login | about

Link: http://codepad.org/BvrfyFBE    [ raw code | fork ]

C++, pasted on Jul 18:
struct A
{
	A() { std::cout << "ctor\n"; }
	A(const A&) { std::cout << "copy-ctor\n"; }
	A(A&&) { std::cout << "move-ctor\n"; }

	A& operator=(const A&)
	{
		std::cout << "operator=\n";
		return *this;
	}
	A& operator=(A&&)
	{
		std::cout << "move operator=\n";
		return *this;
	}
};

struct B
{
	A	a;
};

int main(int argc, char* argv[])
{
	A	a1;
	A	a2 = std::move(a1);
	B	b1;
	B	b2 = std::move(b1); // Aのコピーコンストラクタが呼ばれる

	return 0;
}


Create a new paste based on this one


Comments: