From e5bef3f97f1c3d285d367e6006855ed653cbb591 Mon Sep 17 00:00:00 2001 From: Automatic Release Builder Date: Thu, 3 Feb 2022 12:52:58 +0000 Subject: [PATCH] Extend simgear::Optional with value_or Needed to allow parity with C++17 use on next --- simgear/misc/simgear_optional.hxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/simgear/misc/simgear_optional.hxx b/simgear/misc/simgear_optional.hxx index 07ad6789..dcfd0ff8 100644 --- a/simgear/misc/simgear_optional.hxx +++ b/simgear/misc/simgear_optional.hxx @@ -74,6 +74,22 @@ public: return _value; } + const T& value_or(const T& defaultValue) const + { + if (!_haveValue) { + return defaultValue; + } + return _value; + } + + T& value_or(T& defaultValue) const + { + if (!_haveValue) { + return defaultValue; + } + return _value; + } + T& value() { if (!_haveValue) {