From f493fccf55f57c3ecdd5564cd5089fcb8546d9bc Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Fri, 2 Jun 2017 18:18:24 -0700 Subject: [PATCH] fix bugs in variant and optional --- src/util/optional.h | 1 + src/util/variant.h | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/util/optional.h b/src/util/optional.h index 699d700..25f0e40 100644 --- a/src/util/optional.h +++ b/src/util/optional.h @@ -401,6 +401,7 @@ public: using base::base; using base::operator=; using base::reset; + using base::emplace; constexpr optional() noexcept = default; template ::is_nothrow_move_assignable) \ - { \ - if(index_value.get() == rt.index_value.get()) \ - { \ - values.move_assign(std::move(rt.values), index_value.get()); \ - } \ - else \ - { \ - values.destruct(index_value.get()); \ - index_value.set(variant_npos); /* in case move_construct throws*/ \ - values.move_construct(std::move(rt), rt.index_value.get()); \ - index_value = rt.index_value; \ - } \ - return *this; \ +#define VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_ASSIGN_OP_true \ + variant_base &operator=(variant_base &&rt) noexcept( \ + detail::variant_values::is_nothrow_move_assignable) \ + { \ + if(index_value.get() == rt.index_value.get()) \ + { \ + values.move_assign(std::move(rt.values), index_value.get()); \ + } \ + else \ + { \ + values.destruct(index_value.get()); \ + index_value.set(variant_npos); /* in case move_construct throws*/ \ + values.move_construct(std::move(rt.values), rt.index_value.get()); \ + index_value = rt.index_value; \ + } \ + return *this; \ } #define VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_ASSIGN_OP_false \ -- 2.30.2