summaryrefslogtreecommitdiff
path: root/asl/option.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'asl/option.hpp')
-rw-r--r--asl/option.hpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/asl/option.hpp b/asl/option.hpp
index e71eb57..4793830 100644
--- a/asl/option.hpp
+++ b/asl/option.hpp
@@ -1,13 +1,30 @@
#pragma once
#include "asl/meta.hpp"
+#include "asl/maybe_uninit.hpp"
namespace asl
{
+struct nullopt_t {};
+static constexpr nullopt_t nullopt{};
+
template<is_object T>
class option
{
+ maybe_uninit<T> m_payload;
+ bool m_has_value = false;
+
+public:
+ constexpr option() = default;
+ constexpr option(nullopt_t) {} // NOLINT(*-explicit-conversions)
+
+ constexpr ~option() = default;
+ constexpr ~option() requires (!trivially_destructible<T>)
+ {
+ if (m_has_value) { m_payload.uninit_unsafe(); }
+ }
+
};
} // namespace asl