From 9cb1b7e37f9a36851ee8f395d1c2343b9cbf5b5d Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Mon, 13 Jul 2020 10:26:59 +0100 Subject: [PATCH] perfect forwarding in apply_visitor alias --- include/mapnik/util/variant.hpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/include/mapnik/util/variant.hpp b/include/mapnik/util/variant.hpp index b77adee05..8b0a7217b 100644 --- a/include/mapnik/util/variant.hpp +++ b/include/mapnik/util/variant.hpp @@ -34,33 +34,21 @@ using recursive_wrapper = typename mapbox::util::recursive_wrapper; template using variant = typename mapbox::util::variant; + // unary visitor interface -// const template -auto VARIANT_INLINE static apply_visitor(F && f, V const& v) -> decltype(V::visit(v, std::forward(f))) +auto VARIANT_INLINE apply_visitor(F&& f, V&& v) + -> decltype(v.visit(std::forward(v), std::forward(f))) { - return V::visit(v, std::forward(f)); -} -// non-const -template -auto VARIANT_INLINE static apply_visitor(F && f, V & v) -> decltype(V::visit(v, std::forward(f))) -{ - return V::visit(v, std::forward(f)); + return v.visit(std::forward(v), std::forward(f)); } // binary visitor interface -// const template -auto VARIANT_INLINE static apply_visitor(F && f, V const& v0, V const& v1) -> decltype(V::binary_visit(v0, v1, std::forward(f))) +auto VARIANT_INLINE apply_visitor(F&& f, V&& v0, V&& v1) + -> decltype(v0.binary_visit(std::forward(v0), std::forward(v1), std::forward(f))) { - return V::binary_visit(v0, v1, std::forward(f)); -} - -// non-const -template -auto VARIANT_INLINE static apply_visitor(F && f, V & v0, V & v1) -> decltype(V::binary_visit(v0, v1, std::forward(f))) -{ - return V::binary_visit(v0, v1, std::forward(f)); + return v0.binary_visit(std::forward(v0), std::forward(v1), std::forward(f)); } // getter interface