Commit 4abe43c1 by Ben Clayton

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.
parent ced82a05
...@@ -50,7 +50,6 @@ class optional { ...@@ -50,7 +50,6 @@ class optional {
// value() returns the contained value, or defaultValue if the optional does // value() returns the contained value, or defaultValue if the optional does
// not contain a value. // not contain a value.
inline T& value(const T& defaultValue);
inline const T& value(const T& defaultValue) const; inline const T& value(const T& defaultValue) const;
// operator bool() returns true if the optional contains a value. // operator bool() returns true if the optional contains a value.
...@@ -120,14 +119,6 @@ const T& optional<T>::value() const { ...@@ -120,14 +119,6 @@ const T& optional<T>::value() const {
} }
template <typename T> template <typename T>
T& optional<T>::value(const T& defaultValue) {
if (!has_value()) {
return defaultValue;
}
return val;
}
template <typename T>
const T& optional<T>::value(const T& defaultValue) const { const T& optional<T>::value(const T& defaultValue) const {
if (!has_value()) { if (!has_value()) {
return defaultValue; return defaultValue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment