diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-03-20 23:22:04 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-03-20 23:22:04 +0000 |
commit | 3f2822035b3f1c67e0d6ce410bf43e84b0846037 (patch) | |
tree | 99200c7d6c6c617afbf7724768bbd5f1098cede8 /lib/persistence.h | |
parent | Lazy initialisation of SelectionPtr in persistValue (diff) | |
download | ilt-3f2822035b3f1c67e0d6ce410bf43e84b0846037.tar.bz2 ilt-3f2822035b3f1c67e0d6ce410bf43e84b0846037.tar.xz ilt-3f2822035b3f1c67e0d6ce410bf43e84b0846037.zip |
Add persistence support for std::optional<>s
Diffstat (limited to 'lib/persistence.h')
-rw-r--r-- | lib/persistence.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/persistence.h b/lib/persistence.h index d38d4b1..cc2e4e5 100644 --- a/lib/persistence.h +++ b/lib/persistence.h @@ -6,6 +6,7 @@ #include <iosfwd> #include <map> #include <memory> +#include <optional> #include <span> #include <special_members.hpp> #include <sstream> @@ -147,6 +148,10 @@ namespace Persistence { } }; + template<typename T> struct SelectionT<std::optional<T>> : public SelectionT<T> { + explicit SelectionT(std::optional<T> & value) : SelectionT<T> {value.emplace()} { } + }; + struct Persistable; struct PersistenceStore { using SelectionFactory = std::function<SelectionPtr()>; |