diff --git a/include/resilient/detail/variant_boost.hpp b/include/resilient/detail/variant_boost.hpp index 6aff67b..db1bf34 100644 --- a/include/resilient/detail/variant_boost.hpp +++ b/include/resilient/detail/variant_boost.hpp @@ -35,28 +35,9 @@ class IsType } }; -template -struct as_boost_variant -{ - using type = same_const_ref_as_t::ImplVariant>; -}; - -template -using as_boost_variant_t = typename as_boost_variant::type; - -// Allow to access the Failable as if it was a varian, so that all the variant functions can be used -template -as_boost_variant_t get_boost_variant(Variant&& v) -{ - return move_if_not_lvalue(v.d_data); -} - -template -using if_is_default_constructible = std::enable_if_t::value>; - template -class Variant;// Forward declare so that we can define is_variant before the implementation +using Variant = boost::variant; template @@ -67,56 +48,6 @@ struct is_variant> : std::true_type {}; template using if_is_variant = std::enable_if_t>::value, void*>; -template -using if_is_not_variant = std::enable_if_t>::value, void*>; - -template -class Variant -{ -// wrap boost variant, providing a more c++17 similar interface. -public: - template, - typename = if_is_default_constructible> - Variant() {} // Use a template parameter U so that the evaluation is postponed - // until instantiation - - template = nullptr> - Variant(Other&& other) - : d_data(move_if_not_lvalue(other.d_data)) {} - - template = nullptr> - Variant(Other&& other) - : d_data(std::forward(other)) {} - - template = nullptr> - Variant& operator=(Other&& other) - { - d_data = move_if_not_lvalue(other.d_data); - return *this; - } - - template = nullptr> - Variant& operator=(Other&& other) - { - d_data = std::forward(other); - return *this; - } - -private: - using ImplVariant = boost::variant; - ImplVariant d_data; - - template - friend class Variant; - - template - friend struct as_boost_variant; - - template - friend as_boost_variant_t get_boost_variant(Variant&& f); - -}; - // Visitor which forwards the value based on the ref-ness of the owning variant template struct RvalueForwardingVisitor @@ -136,7 +67,7 @@ struct RvalueForwardingVisitor template = nullptr> bool holds_alternative(Variant&& variant) // TODO make it fail to compile if the variant can not hold T { - return boost::apply_visitor(IsType(), get_boost_variant(std::forward(variant))); + return boost::apply_visitor(IsType(), std::forward(variant)); } #if BOOST_STRICT_GET_NO_RVAL_SUPPORT @@ -155,7 +86,7 @@ auto get(Variant&& variant) -> same_const_ref_as_t // Put boost::strict_get in the scope and use the unscoped call so that the overload we defined can be found using boost::strict_get; using resilient::detail::strict_get; - return strict_get(get_boost_variant(std::forward(variant))); + return strict_get(std::forward(variant)); } template = nullptr> @@ -164,7 +95,7 @@ decltype(auto) visit(Visitor&& visitor, Variant&& variant) // Boost does not support r-value visitors or variants in apply_visitor. // We wrap the visitor so that we do the forwarding. RvalueForwardingVisitor wrapper{visitor}; - return boost::apply_visitor(wrapper, get_boost_variant(variant)); + return boost::apply_visitor(wrapper, variant); } }