From 53697d4a36fdce313dd772b54379f1c3c981cdd5 Mon Sep 17 00:00:00 2001 From: Simon Brand Date: Wed, 1 May 2019 09:40:40 +0100 Subject: [PATCH] Make take always move Fixes #23 --- tl/optional.hpp | 44 ++------------------------------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/tl/optional.hpp b/tl/optional.hpp index c52ea2f..e33682c 100644 --- a/tl/optional.hpp +++ b/tl/optional.hpp @@ -1032,32 +1032,12 @@ public: #endif /// Takes the value out of the optional, leaving it empty - optional take() & { - optional ret = *this; - reset(); - return ret; - } - - optional take() const & { - optional ret = *this; - reset(); - return ret; - } - - optional take() && { + optional take() { optional ret = std::move(*this); reset(); return ret; } -#ifndef TL_OPTIONAL_NO_CONSTRR - optional take() const && { - optional ret = std::move(*this); - reset(); - return ret; - } -#endif - using value_type = T; /// Constructs an optional that does not contain a value. @@ -1926,32 +1906,12 @@ public: #endif /// Takes the value out of the optional, leaving it empty - optional take() & { - optional ret = *this; - reset(); - return ret; - } - - optional take() const & { - optional ret = *this; - reset(); - return ret; - } - - optional take() && { + optional take() { optional ret = std::move(*this); reset(); return ret; } -#ifndef TL_OPTIONAL_NO_CONSTRR - optional take() const && { - optional ret = std::move(*this); - reset(); - return ret; - } -#endif - using value_type = T &; /// Constructs an optional that does not contain a value.