diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-02-28 01:24:18 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-02-28 01:24:18 +0000 |
commit | 7a70e75656d31428c9bbbd51fbf1ca920e577ed1 (patch) | |
tree | fcaed03c9b094e8b37d8d787f6695e8306031a3c /lib/persistence.h | |
parent | Support for named colours in assets (diff) | |
download | ilt-7a70e75656d31428c9bbbd51fbf1ca920e577ed1.tar.bz2 ilt-7a70e75656d31428c9bbbd51fbf1ca920e577ed1.tar.xz ilt-7a70e75656d31428c9bbbd51fbf1ca920e577ed1.zip |
Remove to specify if the Selection pointer type is shared or not
Inferred based on whether the pointer is copyable or not.
Diffstat (limited to 'lib/persistence.h')
-rw-r--r-- | lib/persistence.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/persistence.h b/lib/persistence.h index bfd27f0..458ba4d 100644 --- a/lib/persistence.h +++ b/lib/persistence.h @@ -381,7 +381,8 @@ namespace Persistence { using SeenSharedObjects = std::map<void *, std::string>; inline SeenSharedObjects seenSharedObjects; - template<typename Ptr, bool shared> struct SelectionPtrBase : public SelectionV<Ptr> { + template<typename Ptr> struct SelectionPtrBase : public SelectionV<Ptr> { + static constexpr auto shared = std::is_copy_assignable_v<Ptr>; using T = typename Ptr::element_type; struct SelectionObj : public SelectionV<Ptr> { struct MakeObjectByTypeName : public SelectionV<Ptr> { @@ -526,13 +527,13 @@ namespace Persistence { } }; - template<typename T> struct SelectionT<std::unique_ptr<T>> : public SelectionPtrBase<std::unique_ptr<T>, false> { - using SelectionPtrBase<std::unique_ptr<T>, false>::SelectionPtrBase; + template<typename T> struct SelectionT<std::unique_ptr<T>> : public SelectionPtrBase<std::unique_ptr<T>> { + using SelectionPtrBase<std::unique_ptr<T>>::SelectionPtrBase; }; - template<typename T> struct SelectionT<std::shared_ptr<T>> : public SelectionPtrBase<std::shared_ptr<T>, true> { - using SelectionPtrBase<std::shared_ptr<T>, true>::SelectionPtrBase; - using SelectionPtrBase<std::shared_ptr<T>, true>::setValue; + template<typename T> struct SelectionT<std::shared_ptr<T>> : public SelectionPtrBase<std::shared_ptr<T>> { + using SelectionPtrBase<std::shared_ptr<T>>::SelectionPtrBase; + using SelectionPtrBase<std::shared_ptr<T>>::setValue; void setValue(std::string && id) override |