From d304d719e9b7c3c40d32fc45993f0ccfd34c556e Mon Sep 17 00:00:00 2001 From: Green Sky Date: Sun, 4 Feb 2024 15:10:34 +0100 Subject: [PATCH] more valueor variants --- solanaceae/util/config_model.inl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/solanaceae/util/config_model.inl b/solanaceae/util/config_model.inl index c86ccfd..a7cafce 100644 --- a/solanaceae/util/config_model.inl +++ b/solanaceae/util/config_model.inl @@ -78,6 +78,38 @@ struct CM_InternalOptional { } } + T& value_or(T& other) { + if (has_value) { + if constexpr (std::is_same_v) { + return b; + } else if constexpr (std::is_same_v) { + return i; + } else if constexpr (std::is_same_v) { + return d; + } else if constexpr (std::is_same_v) { + return s; + } + } else { + return other; + } + } + + const T& value_or(const T& other) const { + if (has_value) { + if constexpr (std::is_same_v) { + return b; + } else if constexpr (std::is_same_v) { + return i; + } else if constexpr (std::is_same_v) { + return d; + } else if constexpr (std::is_same_v) { + return s; + } + } else { + return other; + } + } + T value_or(T&& other) { if (has_value) { if constexpr (std::is_same_v) {