Skip to content

Commit 6247207

Browse files
committedMay 1, 2017
add test for ref #147 + #147
1 parent e01b7bf commit 6247207

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed
 

‎test/t/recursive_wrapper.cpp

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
21
#include "catch.hpp"
32

3+
#include <mapbox/variant.hpp>
44
#include <mapbox/recursive_wrapper.hpp>
55

66
#include <type_traits>
@@ -153,6 +153,33 @@ TEST_CASE("recursive wrapper of pair<int, int>")
153153
b = std::move(c);
154154
REQUIRE(b.get().first == 5);
155155
REQUIRE(b.get().second == 6);
156-
// REQUIRE(c.get_pointer() == nullptr);
156+
//REQUIRE(c.get_pointer() == nullptr);
157+
}
158+
159+
SECTION("Multiple recurssive wrappers of polymorphic types")
160+
{
161+
// https://github.com/mapbox/variant/issues/146
162+
// (Visual Studio 2015 update 3)
163+
using namespace mapbox::util;
164+
struct Base;
165+
struct Derived;
166+
using Variant = variant<recursive_wrapper<Base>, recursive_wrapper<Derived>>;
167+
struct Base { };
168+
struct Derived : public Base { };
169+
{
170+
Base base;
171+
Derived derived;
172+
Variant v;
173+
v = base;
174+
v = derived; // compile error prior https://github.com/mapbox/variant/pull/147
175+
CHECK(v.is<Derived>());
176+
}
177+
{
178+
Derived derived;
179+
Variant v(derived); // compile error prior https://github.com/mapbox/variant/pull/147
180+
CHECK(v.is<Derived>());
181+
}
182+
183+
157184
}
158185
}

0 commit comments

Comments
 (0)
Please sign in to comment.