diff options
author | Chris Robinson <[email protected]> | 2019-09-20 10:58:29 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-09-20 10:58:29 -0700 |
commit | b9daffe1590b12b103f9706dfb0a440b629f3c49 (patch) | |
tree | 518977382c07d82be18299748b68f18dde3b92c5 /common/aloptional.h | |
parent | 057b253adba81430e51ce07951eda7dda03f7a08 (diff) |
Don't clean up more than necessary on destruction
Diffstat (limited to 'common/aloptional.h')
-rw-r--r-- | common/aloptional.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/common/aloptional.h b/common/aloptional.h index 79827482..269cba0e 100644 --- a/common/aloptional.h +++ b/common/aloptional.h @@ -9,7 +9,7 @@ namespace al { -#define REQUIRES(...) bool _rt=true, typename std::enable_if<_rt && (__VA_ARGS__),int>::type = 0 +#define REQUIRES(...) bool rt_=true, typename std::enable_if<rt_ && (__VA_ARGS__),bool>::type = true struct nullopt_t { }; struct in_place_t { }; @@ -61,7 +61,7 @@ public: !std::is_constructible<U&&, T>::value)> constexpr optional(U&& value) : mHasValue{true}, mValue{std::forward<U>(value)} { } - ~optional() { reset(); } + ~optional() { if(mHasValue) al::destroy_at(std::addressof(mValue)); } optional& operator=(nullopt_t) noexcept { reset(); return *this; } template<REQUIRES(std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value)> |