fix bugs in variant and optional
authorJacob Lifshay <programmerjake@gmail.com>
Sat, 3 Jun 2017 01:18:24 +0000 (18:18 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Sat, 3 Jun 2017 01:18:24 +0000 (18:18 -0700)
src/util/optional.h
src/util/variant.h

index 699d7009a14da2afc21c449bf360d25ca12407ca..25f0e40afbf4ea8d144c90cb4725276971a7e44e 100644 (file)
@@ -401,6 +401,7 @@ public:
     using base::base;
     using base::operator=;
     using base::reset;
+    using base::emplace;
     constexpr optional() noexcept = default;
     template <typename U,
               typename = typename std::
index 3e49e29968e0784246b62d5908512bedefb49430..f7e6260f10bebe87ce93b363b1ebaeba0fcefa9c 100644 (file)
@@ -768,7 +768,7 @@ struct variant_base;
         {                                                                     \
             values.destruct(index_value.get());                               \
             index_value.set(variant_npos); /* in case copy_construct throws*/ \
-            values.copy_construct(rt, rt.index_value.get());                  \
+            values.copy_construct(rt.values, rt.index_value.get());           \
             index_value = rt.index_value;                                     \
         }                                                                     \
         return *this;                                                         \
@@ -777,22 +777,22 @@ struct variant_base;
 #define VULKAN_CPU_UTIL_VARIANT_BASE_COPY_ASSIGN_OP_false \
     variant_base &operator=(const variant_base &rt) = delete;
 
-#define VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_ASSIGN_OP_true                      \
-    variant_base &operator=(variant_base &&rt) noexcept(                      \
-        detail::variant_values<Types...>::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<Types...>::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 \