From d5fbd2001b0ad3591a7f969dfd75c809ab55b40e Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Fri, 30 Jun 2023 04:34:10 +1000 Subject: RenderPrimitive micro-optimizations --- source/core/StarVariant.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/core/StarVariant.hpp') 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 #include +#include #include "StarAlgorithm.hpp" #include "StarMaybe.hpp" @@ -70,6 +71,22 @@ public: template > Variant(T&& x); + template , typename... Args, + typename std::enable_if< std::is_constructible::value, int >::type = 0 + > + Variant(std::in_place_type_t, Args&&... args) { + new (&m_buffer) T(forward(args)...); + m_typeIndex = TypeIndex::value; + } + + template , typename... Args, + typename std::enable_if< std::is_constructible&, Args...>::value, int >::type = 0 + > + Variant(std::in_place_type_t, std::initializer_list il, Args&&... args) { + new (&m_buffer) T(il, forward(args)...); + m_typeIndex = TypeIndex::value; + } + Variant(Variant const& x); Variant(Variant&& x) noexcept(detail::IsNothrowMoveConstructible::value); -- cgit v1.2.3