diff --git a/include/boost/json/detail/parse_into.hpp b/include/boost/json/detail/parse_into.hpp index dc1ff2733..32e65ddb5 100644 --- a/include/boost/json/detail/parse_into.hpp +++ b/include/boost/json/detail/parse_into.hpp @@ -587,8 +587,6 @@ class converting_handler return false; } - inserter = detail::inserter(*value_, inserter_implementation()); - return converting_handler::composite_handler::signal_end(ec); } @@ -599,6 +597,7 @@ class converting_handler this->inner_active_ = true; clear_container( *value_, inserter_implementation() ); + inserter = detail::inserter(*value_, inserter_implementation()); return true; } diff --git a/test/parse_into.cpp b/test/parse_into.cpp index c6f8e9f2a..565ea1db5 100644 --- a/test/parse_into.cpp +++ b/test/parse_into.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -326,6 +327,17 @@ class parse_into_test parse_into(v, "[5,6,7]"); BOOST_TEST( v.size() == 3 ); + + // containers that are filled through an insert iterator + testParseInto< std::vector> >( + { {}, { 1 }, { 2, 3 }, { 4, 5, 6 } } ); + + container::flat_set s; + parse_into(s, "[1,2,3,4]"); + BOOST_TEST( s.size() == 4 ); + + parse_into(s, "[5,6,7]"); + BOOST_TEST( s.size() == 3 ); } void testMap()