diff options
-rw-r--r-- | icespider/core/util.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/icespider/core/util.h b/icespider/core/util.h index 406faba..cb4f42a 100644 --- a/icespider/core/util.h +++ b/icespider/core/util.h @@ -15,6 +15,16 @@ namespace std::experimental::Ice { } return tf(); } + + template<typename T, typename TF> + auto + operator/(Ice::optional<T> && o, const TF & tf) -> decltype(tf()) + { + if (o) { + return std::move(*o); + } + return tf(); + } } namespace std { @@ -27,6 +37,16 @@ namespace std { } return tf(); } + + template<typename T, typename TF> + auto + operator/(std::optional<T> && o, const TF & tf) -> decltype(tf()) + { + if (o) { + return std::move(*o); + } + return tf(); + } } template<typename T> |