#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) -> decltype(std::declval().get()(sprout::forward(t))) const { return v_.get()(sprout::forward(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