mirror of
https://github.com/boostorg/optional.git
synced 2026-07-21 13:43:39 +00:00
fix constexpr reset
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user