/*============================================================================= Copyright (c) 2011-2019 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_VARIANT_AS_VARIANT_VISITOR_HPP #define SPROUT_VARIANT_AS_VARIANT_VISITOR_HPP #include #include #include #include #include #include #include #include namespace sprout { // // variant_visitor_wrapper // template class variant_visitor_wrapper : public sprout::static_variant_visitor { public: typedef Visitor visitor_type; typedef sprout::value_holder holder_type; private: holder_type v_; public: SPROUT_CONSTEXPR explicit variant_visitor_wrapper(typename holder_type::param_type v) : v_(v) {} template SPROUT_CONSTEXPR auto operator()(T&& t) const -> decltype(std::declval().get()(SPROUT_FORWARD(T, t))) { return v_.get()(SPROUT_FORWARD(T, t)); } }; // // as_variant_visitor // template inline SPROUT_CONSTEXPR sprout::variant_visitor_wrapper::type>::type> as_variant_visitor(Visitor&& visitor) { typedef sprout::variant_visitor_wrapper::type>::type> type; return type(sprout::lvalue_forward(visitor)); } } // namespace sprout #endif // #ifndef SPROUT_VARIANT_AS_VARIANT_VISITOR_HPP