#include <iostream>
#include <utility>
using namespace std;
struct bar
{
int i;
bar() : i(0) {}
explicit bar(int i0) : i(i0) {}
bar(bar const & b) : i(b.i) { cout << "copy ctor " << i << endl; }
bar(bar && b) : i(move(b.i)) { cout << "move ctor " << i << endl; }
};
struct foo
{
bar a, b;
foo() : a(), b() {}
template<class T1, class T2>
foo(T1 && i0, T2 && i1) : a(forward<T1 &&>(i0)), b(forward<T2 &&>(i1)) {}
};
int main(){
bar b1(1), b2(2);
foo f1(b1, b2);
foo f2(b1, bar(3));
foo f3(bar(4), b2);
foo f4(bar(5), bar(6));
foo f5(7, 8);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dXRpbGl0eT4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpzdHJ1Y3QgYmFyCnsKCWludCBpOwoJYmFyKCkgOiBpKDApIHt9CglleHBsaWNpdCBiYXIoaW50IGkwKSA6IGkoaTApIHt9CgliYXIoYmFyIGNvbnN0ICYgYikgOiBpKGIuaSkgeyBjb3V0IDw8ICJjb3B5IGN0b3IgIiA8PCBpIDw8IGVuZGw7IH0KCWJhcihiYXIgJiYgYikgOiBpKG1vdmUoYi5pKSkgeyBjb3V0IDw8ICJtb3ZlIGN0b3IgIiA8PCBpIDw8IGVuZGw7IH0KfTsKCnN0cnVjdCBmb28KewoJYmFyIGEsIGI7Cglmb28oKSA6IGEoKSwgYigpIHt9CgoJdGVtcGxhdGU8Y2xhc3MgVDEsIGNsYXNzIFQyPgoJZm9vKFQxICYmIGkwLCBUMiAmJiBpMSkgOiBhKGZvcndhcmQ8VDEgJiY+KGkwKSksIGIoZm9yd2FyZDxUMiAmJj4oaTEpKSB7fQp9OwoKaW50IG1haW4oKXsKCWJhciBiMSgxKSwgYjIoMik7Cglmb28gZjEoYjEsIGIyKTsKCWZvbyBmMihiMSwgYmFyKDMpKTsKCWZvbyBmMyhiYXIoNCksIGIyKTsKCWZvbyBmNChiYXIoNSksIGJhcig2KSk7CgoJZm9vIGY1KDcsIDgpOwp9Cg==