diff --git a/idl/idl_test.idl.hh b/idl/idl_test.idl.hh index aa1053413c..a67e86cfa0 100644 --- a/idl/idl_test.idl.hh +++ b/idl/idl_test.idl.hh @@ -86,3 +86,12 @@ struct empty_final_struct final { }; struct just_a_variant stub [[writable]] { std::variant variant; }; + +template +struct const_template_arg_wrapper { + T x; +} + +struct const_template_arg_test_object { + std::vector> first; +}; diff --git a/test/boost/idl_test.cc b/test/boost/idl_test.cc index a8eae97c5d..68271d4065 100644 --- a/test/boost/idl_test.cc +++ b/test/boost/idl_test.cc @@ -145,6 +145,27 @@ public: } }; +template +struct const_template_arg_wrapper { + T x; + + const_template_arg_wrapper(const T& t) + : x(t) + {} + + bool operator == (const const_template_arg_wrapper& rhs) const { + return x == rhs.x; + } +}; + +struct const_template_arg_test_object { + std::vector> first; + + bool operator == (const const_template_arg_test_object& rhs) const { + return first == rhs.first; + } +}; + #include "serialization_visitors.hh" #include "idl/idl_test.dist.hh" #include "serializer_impl.hh" @@ -445,3 +466,21 @@ BOOST_AUTO_TEST_CASE(test_fragmented_write) BOOST_CHECK_EQUAL(deserialized, fragment_generator(fragment_count, fragment_size).to_bytes()); } } + +BOOST_AUTO_TEST_CASE(test_const_template_arg) +{ + const_template_arg_test_object obj { + .first = { + simple_compound{ 0xdeadbeef, 0xbadc0ffe }, + simple_compound{ 0xbaaaaaad, 0xdeadc0de } + } + }; + + bytes_ostream buf; + ser::serialize(buf, obj); + BOOST_REQUIRE_EQUAL(buf.size(), 40); + + auto in = ser::as_input_stream(buf); + auto deser_obj = ser::deserialize(in, boost::type()); + BOOST_REQUIRE(obj == deser_obj); +}