From cc3ed655ac4241cdedfb0f3774df15e76ce55982 Mon Sep 17 00:00:00 2001 From: Vesa Karvonen Date: Mon, 16 Sep 2019 23:54:08 +0300 Subject: [PATCH 1/2] Try to reproduce issue with VC --- internals/tests/testing/defaulted_test.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internals/tests/testing/defaulted_test.cpp b/internals/tests/testing/defaulted_test.cpp index fa0ea95..cfdbf45 100644 --- a/internals/tests/testing/defaulted_test.cpp +++ b/internals/tests/testing/defaulted_test.cpp @@ -23,4 +23,12 @@ auto defaulted_test = test([]() { dumpster_v1::zeroed x; verify(x == nullptr); } + { + dumpster_v1::zeroed x; + dumpster_v1::zeroed y = x; + y += 1; + x = y; + x = 2 * y + 1; + verify(3 == x); + } }); From 52000a5c6933a9a270701906f7da7d48fad9822f Mon Sep 17 00:00:00 2001 From: Vesa Karvonen Date: Tue, 17 Sep 2019 00:30:22 +0300 Subject: [PATCH 2/2] Add operator= for direct assignment to defaulted `value` --- provides/include/dumpster_v1/defaulted.hpp | 7 +++++++ provides/include/dumpster_v1/synopsis.hpp | 3 +++ 2 files changed, 10 insertions(+) diff --git a/provides/include/dumpster_v1/defaulted.hpp b/provides/include/dumpster_v1/defaulted.hpp index 2a997df..4428a77 100644 --- a/provides/include/dumpster_v1/defaulted.hpp +++ b/provides/include/dumpster_v1/defaulted.hpp @@ -21,3 +21,10 @@ template dumpster_v1::defaulted::operator Value &() { return value; } + +template +template +Value &dumpster_v1::defaulted:: +operator=(Forwardable &&rhs) { + return value = std::forward(rhs); +} diff --git a/provides/include/dumpster_v1/synopsis.hpp b/provides/include/dumpster_v1/synopsis.hpp index a3c1592..ba39562 100644 --- a/provides/include/dumpster_v1/synopsis.hpp +++ b/provides/include/dumpster_v1/synopsis.hpp @@ -23,6 +23,9 @@ template struct defaulted { /// Implicit conversion to reference for convenience. operator Value &(); + /// Assigns given `rhs` to `value` member. + template Value &operator=(Forwardable &&rhs); + /// The value is directly accessible as there is no reason to hide it. Value value; };