#include #include #include #include "common.h" using namespace alsk; namespace { using Data = Measure; struct Opv { template void operator()(Ts&&...) {} }; struct Op { template Data operator()(Ts&&...) { return {}; } }; /* NOTE: * `Data const&` causes a copy when then stored in Data * to avoid: simply return `Data` instead or store in `Data&` * hw uses one `auto` to enables this */ struct Opr { template Data const& operator()(Data const& a, Ts&&...) { return a; } }; using Struct = S; using Links = L(Data const&), void(arg::P<0>), Data(arg::P<0>), Data(arg::R<1> const&), Data(arg::P<0>, arg::R<1> const&, arg::R<2> const&) >; using Test = BuildSkeletonT; void hw(Data const& p0) { Opv{}(p0); decltype(auto) r1 = Op{}(p0); auto r2 = Opr{}(r1); decltype(auto) r3 = Op{}(p0, r1, r2); static_cast(r3); } } TEST_CASE("Copy") { std::size_t bCopy, bMove, sCopy, sMove; _copy = _move = 0; hw({}); bCopy = _copy; bMove = _move; auto test = implement(); _copy = _move = 0; test({}); sCopy = _copy; sMove = _move; CAPTURE(bCopy); CAPTURE(sCopy); REQUIRE(bCopy >= sCopy); REQUIRE(bMove <= sMove); }