mapbox/variant

is<T> fails for recursive_wrapper

jfirebaugh opened this issue · 1 comments

The following test case fails to compile:

TEST_CASE("recursive wrapper")
{
    using variant_type = mapbox::util::variant<mapbox::util::recursive_wrapper<int>>;
    variant_type v(1);
    REQUIRE(v.get<int>() == 1);
    REQUIRE(v.is<int>());
}

The error is:

./variant.hpp:659:9: error: static_assert failed "invalid type in T in `is<T>()` for this variant"
        static_assert(detail::has_type<T, Types...>::value, "invalid type in T in `is<T>()` for this variant");
        ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

get<T>() works because it has been specialized for recursive_wrapper-wrapped types. is<T>() should do the same.

specialisation added + test updated in c6ae1ea