From 4abe43c1310668dc8b9d51d8708907fcb3f00a4b Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Wed, 22 Jan 2020 12:00:02 +0000 Subject: [PATCH] optional: Remove the value() method that returns non-const-ref. I'm not convinced that `opt.value() = foo` is a desirable pattern, and worse still it confuses some compilers about which overload to use. Just remove it. --- include/dap/optional.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/include/dap/optional.h b/include/dap/optional.h index deab3f7..06b298c 100644 --- a/include/dap/optional.h +++ b/include/dap/optional.h @@ -50,7 +50,6 @@ class optional { // value() returns the contained value, or defaultValue if the optional does // not contain a value. - inline T& value(const T& defaultValue); inline const T& value(const T& defaultValue) const; // operator bool() returns true if the optional contains a value. @@ -119,14 +118,6 @@ const T& optional::value() const { return val; } -template -T& optional::value(const T& defaultValue) { - if (!has_value()) { - return defaultValue; - } - return val; -} - template const T& optional::value(const T& defaultValue) const { if (!has_value()) {