fix constexpr reset

This commit is contained in:
Andrzej Krzemienski
2026-02-07 13:36:08 +01:00
parent 7b078be18d
commit c81b9b098b
@@ -112,6 +112,8 @@ struct constexpr_guarded_storage
constexpr explicit constexpr_guarded_storage(optional_ns::in_place_init_t, ::std::initializer_list<U> il, Args&&... args)
: init_(true), storage_(il, forward_<Args>(args)...) {}
constexpr void reset () noexcept { init_ = false; }
~constexpr_guarded_storage() = default;
};
@@ -135,6 +137,16 @@ struct fallback_guarded_storage
explicit fallback_guarded_storage(optional_ns::in_place_init_t, ::std::initializer_list<U> il, Args&&... args)
: init_(true), storage_(il, forward_<Args>(args)...) {}
void reset() noexcept
{
if (init_)
{
storage_.value_.T::~T();
init_ = false;
}
}
~fallback_guarded_storage() { if (init_) storage_.value_.T::~T(); }
};
@@ -260,8 +272,7 @@ namespace boost {
constexpr void reset() noexcept
{
if (is_initialized()) dataptr()->T::~T();
storage.init_ = false;
storage.reset();
}
BOOST_OPTIONAL_CXX20_CONSTEXPR void reset(const T& v)