From 55486b49dc2fd774de42f3d1c1efdebde83ca78a Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Thu, 16 Nov 2023 23:39:19 +0100 Subject: [PATCH] Fixed optional move constructor for references. --- source/mijin/container/optional.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/mijin/container/optional.hpp b/source/mijin/container/optional.hpp index 57b2ac4..4e9148d 100644 --- a/source/mijin/container/optional.hpp +++ b/source/mijin/container/optional.hpp @@ -173,7 +173,12 @@ Optional::Optional(Optional&& other) noexcept { if (other) { - emplace(std::move(other.get())); + if constexpr (!std::is_reference_v) { + emplace(std::move(other.get())); + } + else { + emplace(other.get()); + } other.reset(); } }