From 31e906c1fbaf3bc9128138302d8db549e87769a7 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 12 Aug 2014 10:09:24 -0700 Subject: Bust the last evil union --- src/sexpr/variant_test.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'src/sexpr/variant_test.cpp') diff --git a/src/sexpr/variant_test.cpp b/src/sexpr/variant_test.cpp index 5a75780..bc378aa 100644 --- a/src/sexpr/variant_test.cpp +++ b/src/sexpr/variant_test.cpp @@ -115,9 +115,43 @@ TEST(variant, match) } } -TEST(variant, copymove) +TEST(variant, copymove1) { sexpr::Variant moveonly(Qux(3)); (void)moveonly; } + +TEST(variant, copymove2) +{ + struct Move + { + Move() = default; + Move(Move&&) = default; + Move(const Move&) = delete; + Move& operator = (Move&&) = default; + Move& operator = (const Move&) = delete; + ~Move() = default; + }; + struct Copy + { + Copy() = default; + Copy(Copy&&) = default; + Copy(const Copy&) = default; + Copy& operator = (Copy&&) = default; + Copy& operator = (const Copy&) = default; + ~Copy() = default; + }; + + using VarMv = sexpr::Variant; + using VarCp = sexpr::Variant; + + VarMv mv1; + VarMv mv3 = std::move(mv1); + mv1 = std::move(mv3); + VarCp cp1; + VarCp cp2 = cp1; + VarCp cp3 = std::move(cp1); + cp1 = cp2; + cp1 = std::move(cp3); +} } // namespace tmwa -- cgit v1.2.3-60-g2f50