Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core/StarVariant.hpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-30 04:34:10 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-30 04:34:10 +1000
commitd5fbd2001b0ad3591a7f969dfd75c809ab55b40e (patch)
treeb6b9361bfa854daf3e6be45d572407508340d12d /source/core/StarVariant.hpp
parent47a527ebbff91cf530cb8758828679ef0e3334f2 (diff)
RenderPrimitive micro-optimizations
Diffstat (limited to 'source/core/StarVariant.hpp')
-rw-r--r--source/core/StarVariant.hpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/core/StarVariant.hpp b/source/core/StarVariant.hpp
index 043cd1d..39779c1 100644
--- a/source/core/StarVariant.hpp
+++ b/source/core/StarVariant.hpp
@@ -3,6 +3,7 @@
#include <type_traits>
#include <utility>
+#include <initializer_list>
#include "StarAlgorithm.hpp"
#include "StarMaybe.hpp"
@@ -70,6 +71,22 @@ public:
template <typename T, typename = ValidateType<T>>
Variant(T&& x);
+ template <typename T, typename = ValidateType<T>, typename... Args,
+ typename std::enable_if< std::is_constructible<T, Args...>::value, int >::type = 0
+ >
+ Variant(std::in_place_type_t<T>, Args&&... args) {
+ new (&m_buffer) T(forward<Args>(args)...);
+ m_typeIndex = TypeIndex<T>::value;
+ }
+
+ template <typename T, typename U, typename = ValidateType<T>, typename... Args,
+ typename std::enable_if< std::is_constructible<T, std::initializer_list<U>&, Args...>::value, int >::type = 0
+ >
+ Variant(std::in_place_type_t<T>, std::initializer_list<U> il, Args&&... args) {
+ new (&m_buffer) T(il, forward<Args>(args)...);
+ m_typeIndex = TypeIndex<T>::value;
+ }
+
Variant(Variant const& x);
Variant(Variant&& x) noexcept(detail::IsNothrowMoveConstructible<FirstType, RestTypes...>::value);