diff --git a/test/box/recursive.cpp b/test/box/recursive.cpp index 4c8fce07..458ffbaf 100644 --- a/test/box/recursive.cpp +++ b/test/box/recursive.cpp @@ -13,6 +13,7 @@ #include #include +#include #include struct rec_vec @@ -106,3 +107,36 @@ TEST_CASE("recursive set") CHECK(v3.children.count(rec_set{13, {}}) == 1); CHECK(v3.children.count(rec_set{14, {}}) == 0); } + +struct a_type; + +struct b_type +{ + b_type(int a, immer::box val); + int a; + immer::box val; +}; + +struct a_type +{ + a_type(); + // this does not work with std::optional, because it seems like + // `immer::box` is still not considered complete at this point... + boost::optional> b; +}; + +b_type::b_type(int a, immer::box val) + : a(a) + , val(val) +{} + +a_type::a_type() + : b{} +{} + +TEST_CASE("recursive optional") +{ + auto x = a_type{}; + auto y = b_type{42, x}; + CHECK(y.a == 42); +}