summaryrefslogtreecommitdiff
path: root/include/fud_option.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/fud_option.hpp')
-rw-r--r--include/fud_option.hpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/include/fud_option.hpp b/include/fud_option.hpp
index f2e86ca..d8b7114 100644
--- a/include/fud_option.hpp
+++ b/include/fud_option.hpp
@@ -19,6 +19,7 @@
#define FUD_OPTION_HPP
#include "fud_assert.hpp"
+#include "fud_algorithm_no_dep.hpp"
#include <cstddef>
#include <functional>
@@ -42,9 +43,8 @@ struct NullOptionType {
template <size_t Size>
struct DataArray {
- // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays)
+ // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays)
std::byte m_data[Size];
- // NOLINTEND(cppcoreguidelines-avoid-c-arrays)
constexpr std::byte* data() noexcept
{
@@ -121,18 +121,6 @@ class Option {
destroy();
}
- constexpr static Option take(T&& value) noexcept
- {
- Option option{};
- option.m_engaged = true;
- if constexpr (IsRef) {
- new (option.m_data.data()) std::reference_wrapper<ValueType>(std::ref(value));
- } else {
- new (option.m_data.data()) ValueType(std::move(value));
- }
- return option;
- }
-
Option& operator=(const Option& rhs) noexcept
{
if (&rhs == this) {
@@ -153,6 +141,18 @@ class Option {
return *this;
}
+ constexpr static Option take(T&& value) noexcept
+ {
+ Option option{};
+ option.m_engaged = true;
+ if constexpr (IsRef) {
+ new (option.m_data.data()) std::reference_wrapper<ValueType>(std::ref(value));
+ } else {
+ new (option.m_data.data()) ValueType(std::move(value));
+ }
+ return option;
+ }
+
[[nodiscard]] bool hasValue() const
{
return m_engaged;
@@ -249,7 +249,7 @@ class Option {
m_data.clear();
}
- static constexpr auto Align = std::max(alignof(ValueType), alignof(std::reference_wrapper<ValueType>));
+ static constexpr auto Align = max(alignof(ValueType), alignof(std::reference_wrapper<ValueType>));
alignas(Align) option_detail::DataArray<Size> m_data{};
bool m_engaged;