diff options
Diffstat (limited to 'source/core')
-rw-r--r-- | source/core/StarVariant.hpp | 17 |
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); |