diff --git a/libs/variant/test/variant.cpp b/libs/variant/test/variant.cpp index 9deaeb4f..9b764b6b 100644 --- a/libs/variant/test/variant.cpp +++ b/libs/variant/test/variant.cpp @@ -170,6 +170,18 @@ namespace testspr { TESTSPR_ASSERT(var3.which() == 0); TESTSPR_ASSERT(sprout::get(var3) == 0); } + { + testspr::x2_visitor visitor1 = {}; + TESTSPR_BOTH_ASSERT(sprout::apply_visitor(visitor1, var1) == 2.0); + TESTSPR_BOTH_ASSERT(sprout::apply_visitor(visitor1, var2) == 0.0); + } + { + auto var3 = var2; + testspr::x2_assign_visitor visitor1 = {}; + TESTSPR_ASSERT(sprout::apply_visitor(visitor1, var3) == 0.0); + TESTSPR_ASSERT(var3.which() == 0); + TESTSPR_ASSERT(sprout::get(var3) == 0); + } // operator<< { diff --git a/sprout/variant/apply_visitor.hpp b/sprout/variant/apply_visitor.hpp index 97ef6c58..4e247d04 100644 --- a/sprout/variant/apply_visitor.hpp +++ b/sprout/variant/apply_visitor.hpp @@ -6,7 +6,7 @@ namespace sprout { template - inline SPROUT_CONSTEXPR typename Visitor::result_type + inline SPROUT_CONSTEXPR typename std::decay::type::result_type apply_visitor(Visitor&& visitor, Visitable&& visitable) { return sprout::forward(visitable).apply_visitor(sprout::forward(visitor)); } diff --git a/sprout/variant/variant.hpp b/sprout/variant/variant.hpp index 37ed0530..7969fecc 100644 --- a/sprout/variant/variant.hpp +++ b/sprout/variant/variant.hpp @@ -127,14 +127,14 @@ namespace sprout { template static SPROUT_CONSTEXPR typename std::enable_if< I == sizeof...(Types), - typename Visitor::result_type + typename std::decay::type::result_type >::type visit(Tuple&& t, Visitor&& v, int which) { - return typename Visitor::result_type(); + return typename std::decay::type::result_type(); } template static SPROUT_CONSTEXPR typename std::enable_if< I != sizeof...(Types), - typename Visitor::result_type + typename std::decay::type::result_type >::type visit(Tuple&& t, Visitor&& v, int which) { return I == which ? sprout::forward(v)(sprout::tuples::get(sprout::forward(t))) @@ -249,11 +249,11 @@ namespace sprout { } // visitation support template - SPROUT_CONSTEXPR typename Visitor::result_type apply_visitor(Visitor&& visitor) const { + SPROUT_CONSTEXPR typename std::decay::type::result_type apply_visitor(Visitor&& visitor) const { return visit<0>(tuple_, sprout::forward(visitor), which_); } template - typename Visitor::result_type apply_visitor(Visitor&& visitor) { + typename std::decay::type::result_type apply_visitor(Visitor&& visitor) { return visit<0>(tuple_, sprout::forward(visitor), which_); } };