diff options
author | kumquat-ir <66188216+kumquat-ir@users.noreply.github.com> | 2021-04-15 23:19:01 -0700 |
---|---|---|
committer | kumquat-ir <66188216+kumquat-ir@users.noreply.github.com> | 2021-04-15 23:19:01 -0700 |
commit | 42253150e43fa4289130d4b53729e618908a251e (patch) | |
tree | 2523976f18503837a72dc2fadfba3304d774fab5 /libraries/toml11/include/toml/storage.hpp | |
parent | 8b926d29d7aef9c7bbcb25ec9bfbf0ad314a8d72 (diff) | |
download | PrismLauncher-42253150e43fa4289130d4b53729e618908a251e.tar.gz PrismLauncher-42253150e43fa4289130d4b53729e618908a251e.tar.bz2 PrismLauncher-42253150e43fa4289130d4b53729e618908a251e.zip |
add toml11 as dependency
Diffstat (limited to 'libraries/toml11/include/toml/storage.hpp')
-rw-r--r-- | libraries/toml11/include/toml/storage.hpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libraries/toml11/include/toml/storage.hpp b/libraries/toml11/include/toml/storage.hpp new file mode 100644 index 00000000..202f9035 --- /dev/null +++ b/libraries/toml11/include/toml/storage.hpp @@ -0,0 +1,43 @@ +// Copyright Toru Niina 2017. +// Distributed under the MIT License. +#ifndef TOML11_STORAGE_HPP +#define TOML11_STORAGE_HPP +#include "utility.hpp" + +namespace toml +{ +namespace detail +{ + +// this contains pointer and deep-copy the content if copied. +// to avoid recursive pointer. +template<typename T> +struct storage +{ + using value_type = T; + + explicit storage(value_type const& v): ptr(toml::make_unique<T>(v)) {} + explicit storage(value_type&& v): ptr(toml::make_unique<T>(std::move(v))) {} + ~storage() = default; + storage(const storage& rhs): ptr(toml::make_unique<T>(*rhs.ptr)) {} + storage& operator=(const storage& rhs) + { + this->ptr = toml::make_unique<T>(*rhs.ptr); + return *this; + } + storage(storage&&) = default; + storage& operator=(storage&&) = default; + + bool is_ok() const noexcept {return static_cast<bool>(ptr);} + + value_type& value() & noexcept {return *ptr;} + value_type const& value() const& noexcept {return *ptr;} + value_type&& value() && noexcept {return std::move(*ptr);} + + private: + std::unique_ptr<value_type> ptr; +}; + +} // detail +} // toml +#endif// TOML11_STORAGE_HPP |