#include using namespace Upp; struct Test : Moveable { Test(const Vector& a, int b) : a(clone(a)), b(b) {} Test(Vector&& a, int b) : a(pick(a)), b(b) {} Test() {} Vector a; int b; }; template void TestCreate() { T h; DLOG("---- Create " << typeid(T).name()); Vector v; v.Add(12); // Copy-constructor h.Create(v, 22); DDUMP(v.GetCount()); ASSERT(v.GetCount() == 1); // Move-constructor h.Create(pick(v), 22); DDUMP(v.GetCount()); ASSERT(v.GetCount() == 0); v.Add(21); h.Create(clone(v), 22); DDUMP(v.GetCount()); ASSERT(v.GetCount() == 1); } template void TestCreateT() { T h; DLOG("---- Create " << typeid(T).name()); Vector v; v.Add(12); // Copy-constructor h.template Create(v, 22); DDUMP(v.GetCount()); ASSERT(v.GetCount() == 1); // Move-constructor h.template Create(pick(v), 22); DDUMP(v.GetCount()); ASSERT(v.GetCount() == 0); v.Add(21); h.template Create(clone(v), 22); DDUMP(v.GetCount()); ASSERT(v.GetCount() == 1); } template void TestCreateMap() { T h; DLOG("---- Create " << typeid(T).name()); Vector v; v.Add(12); // Copy-constructor h.template Create("a", v, 22); DDUMP(v.GetCount()); ASSERT(v.GetCount() == 1); // Move-constructor h.template Create("a", pick(v), 22); DDUMP(v.GetCount()); ASSERT(v.GetCount() == 0); v.Add(21); h.template Create("a", clone(v), 22); DDUMP(v.GetCount()); ASSERT(v.GetCount() == 1); } CONSOLE_APP_MAIN { StdLogSetup(LOG_COUT|LOG_FILE); TestCreate>(); TestCreateT>(); TestCreateT(); TestCreate>(); TestCreateT>(); TestCreateT>(); TestCreateMap>(); TestCreateMap>(); TestCreateMap>(); LOG("======== OK"); }