summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2020-12-28 11:52:52 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2020-12-28 11:52:52 +0000
commitbd8b41d78d2dbcbd60528e2bb30e4bcc84556d43 (patch)
tree3c66871e6774b098a95ba07b2173d9a1fc1bc7a2
parentModern LTO options (diff)
downloadicespider-bd8b41d78d2dbcbd60528e2bb30e4bcc84556d43.tar.bz2
icespider-bd8b41d78d2dbcbd60528e2bb30e4bcc84556d43.tar.xz
icespider-bd8b41d78d2dbcbd60528e2bb30e4bcc84556d43.zip
Add moving variant of operator/ for optionals
-rw-r--r--icespider/core/util.h20
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>