Closed lsix closed 2 years ago
Starting to take a look at this PR. It will take a bit for me to verify everything. Sorry I'm going slow.
Starting to take a look at this PR. It will take a bit for me to verify everything. Sorry I'm going slow.
That is fine, take your time! If you have any question please come back to me (everything is not fresh in my mind but I can dig back into it, no problem!)
Sadly, the current CI setup doesn't build src/tests/..., so this PR breaks those. I will fix them up.
Oh, I see them failing in the 3.9 build. I will still fix those.
ais8_1_22_test.cc:126:55: error: cannot dynamic_cast ‘msg.libais::Ais8_1_22::sub_areas.std::vector<_Tp, _Alloc>::operator[]<std::unique_ptr<libais::Ais8_1_22_SubArea>, std::allocator<std::unique_ptr<libais::Ais8_1_22_SubArea> > >(1ul)’ (of type ‘__gnu_cxx::__alloc_traits<std::allocator<std::unique_ptr<libais::Ais8_1_22_SubArea> > >::value_type {aka class std::unique_ptr<libais::Ais8_1_22_SubArea>}’) to type ‘class libais::Ais8_1_22_Polygon*’ (source is not a pointer)
dynamic_cast<Ais8_1_22_Polygon *>(msg.sub_areas[1]);
This PR is the first part of the resubmitted #209 .
This PR includes a first patch that proposes to use
std::unique_ptr
to manage subareas inAis8_1_22
andAis8_366_22
. The current implementation uses raw pointers and relies on destructors in order to do clean-up. Thestd::unique_ptr
implementation is usually considered safer and less error prone.The second patch changes some
reinterpred_cast
intodynamic_cast
when casting from a pointer to parent class into a pointer to a child class.Both commits are kept together because they inpact common lines.