Boost logo

Boost :

Subject: [boost] [serialization] Custom archive and arrays
From: Bjorn Reese (breese_at_[hidden])
Date: 2016-01-22 05:40:41


I am currently adding support of C++ arrays to a custom oarchive.

My archive inherits from boost::archive::detail::common_oarchive and
implements save_override(), which will pass any unknown type to
boost::archive::save(). This enables me to implement non-intrusive
serialization.

When I pass an array to boost::archive::save(), it detects that this is
an array and then calls detail::save_array_type. This is where my
problem starts, as the function is hardcoded to always store a prefixed
array count, which is illegal in the format that my custom archive uses.

Would it be possible to lift this restriction?

My current workaround is to add an overload for arrays to my custom
archive, i.e.

     template <typename T, std::size_t N>
     void save_override(const T (&data)[N]);


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk