#include "catch.hpp" #include #include #include template struct mutating_visitor { mutating_visitor(T& val) : val_(val) {} void operator()(T& val) const { val = val_; } template void operator()(T1&) const { } // no-op T& val_; }; TEST_CASE("variant visitation", "[visitor][unary visitor]") { mapbox::util::variant var(123); REQUIRE(var.get() == 123); int val = 456; const mutating_visitor visitor(val); mapbox::util::apply_visitor(visitor, var); REQUIRE(var.get() == 456); }