diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-02-17 00:21:48 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-02-17 22:29:50 +0100 |
commit | a141c401f78467bc15f62882fca5d55a007cacbb (patch) | |
tree | 908ac71a8640f78f45d22c6808c5fa6e373000fa /asl/maybe_uninit.hpp | |
parent | cb77cbe9ce4cddad6a460aa190ff70f0c13e4703 (diff) |
Reorganize everything
Diffstat (limited to 'asl/maybe_uninit.hpp')
-rw-r--r-- | asl/maybe_uninit.hpp | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/asl/maybe_uninit.hpp b/asl/maybe_uninit.hpp deleted file mode 100644 index a69f39b..0000000 --- a/asl/maybe_uninit.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include "asl/meta.hpp" -#include "asl/utility.hpp" -#include "asl/memory.hpp" - -namespace asl -{ - -template<is_object T> -union maybe_uninit -{ -private: - T m_value; - -public: - constexpr maybe_uninit() requires trivially_default_constructible<T> = default; - constexpr maybe_uninit() requires (!trivially_default_constructible<T>) {} // NOLINT - - template<typename... Args> - explicit constexpr maybe_uninit(in_place_t, Args&&... args) - requires constructible_from<T, Args&&...> - : m_value{ASL_FWD(args)...} - {} - - constexpr maybe_uninit(const maybe_uninit&) requires trivially_copy_constructible<T> = default; - constexpr maybe_uninit(const maybe_uninit&) requires (!trivially_copy_constructible<T>) {} // NOLINT - - constexpr maybe_uninit(maybe_uninit&&) requires trivially_move_constructible<T> = default; - constexpr maybe_uninit(maybe_uninit&&) requires (!trivially_move_constructible<T>) {} // NOLINT - - constexpr maybe_uninit& operator=(const maybe_uninit&) requires trivially_copy_assignable<T> = default; - constexpr maybe_uninit& operator=(const maybe_uninit&) requires (!trivially_copy_assignable<T>) {} - - constexpr maybe_uninit& operator=(maybe_uninit&&) requires trivially_move_assignable<T> = default; - constexpr maybe_uninit& operator=(maybe_uninit&&) requires (!trivially_move_assignable<T>) {} - - constexpr ~maybe_uninit() requires trivially_destructible<T> = default; - constexpr ~maybe_uninit() requires (!trivially_destructible<T>) {} // NOLINT - - // @Safety Value must not have been initialized yet - template<typename... Args> - constexpr void construct_unsafe(Args&&... args) - requires constructible_from<T, Args&&...> - { - construct_at<T>(&m_value, ASL_FWD(args)...); - } - - // @Safety Value must have been initialized - template<typename U> - constexpr void assign_unsafe(U&& value) - requires assignable_from<T&, U&&> - { - m_value = ASL_FWD(value); - } - - // @Safety Value must have been initialized - constexpr void destroy_unsafe() - { - if constexpr (!trivially_destructible<T>) - { - destroy(&m_value); - } - } - - // @Safety Value must have been initialized - constexpr const T& as_init_unsafe() const& { return m_value; } - constexpr T& as_init_unsafe() & { return m_value; } - constexpr T&& as_init_unsafe() && { return ASL_MOVE(m_value); } -}; - -} // namespace asl |