#ifndef RFL_VARIANT_HPP_ #define RFL_VARIANT_HPP_ #include namespace rfl { template struct Variant { /// The type of the underlying variant. using VariantType = std::variant; Variant(const VariantType& _variant) : variant_(_variant) {} Variant(VariantType&& _variant) noexcept : variant_(std::move(_variant)) {} Variant(const Variant& _variant) = default; Variant(Variant&& _variant) noexcept = default; template < class T, typename std::enable_if, bool>:: type = true> Variant(const T& _t) : variant_(_t) {} template < class T, typename std::enable_if, bool>:: type = true> Variant(T&& _t) noexcept : variant_(std::forward(_t)) {} ~Variant() = default; /// Assigns the underlying object. Variant& operator=(const VariantType& _variant) { variant_ = _variant; return *this; } /// Assigns the underlying object. Variant& operator=(VariantType&& _variant) { variant_ = std::move(_variant); return *this; } /// Assigns the underlying object. template < class T, typename std::enable_if, bool>:: type = true> Variant& operator=(T&& _variant) { variant_ = std::forward(_variant); return *this; } /// Assigns the underlying object. template < class T, typename std::enable_if, bool>:: type = true> Variant& operator=(const T& _variant) { variant_ = _variant; return *this; } /// Assigns the underlying object. Variant& operator=( const Variant& _other ) = default; /// Assigns the underlying object. Variant& operator=( Variant&& _other ) = default; /// Returns the underlying variant. VariantType& variant() { return variant_; } /// Returns the underlying variant. const VariantType& variant() const { return variant_; } /// The underlying variant - a Variant is a thin wrapper /// around a variant that is mainly used for parsing. VariantType variant_; }; } // namespace rfl #endif