
It is not very convenient for me to use macros like BOOST_SERIALIZATION_SPLIT_FREE, BOOST_SERIALIZATION_SPLIT_MEMBER to deal with splitted load/save functions. Additionally, when dealing with load/save functions of template class, these macros help little. Users also have to read and understand what these macros actually do and write their own serialize function to call split_free or split_member accordingly. I suggest that these implementation details on how the serialization library determine to use single serialize function or splitted load/save functions should be totally encapsulated and hidden behind the scene. I suggest that a traits class to be used by the user instead of macros like BOOST_SERIALIZATION_SPLIT_FREE. For example, the traits class can be named "serialization_traits", its default implementation is somthing as follows: template <typename T> struct serialization_traits { static const bool has_split_load_save = false; }; It can be (partially) specialized for types that has split load/save functions. Then, the serialization library can use this traits class to determine whether to call a single serialize function or splitted load/save functions for a specific type. Am I missing something? Best regards. Yao, Zhen

"Allen Yao" <yaozhen@ustc.edu> wrote
I suggest that a traits class to be used by the user instead of macros like BOOST_SERIALIZATION_SPLIT_FREE. For example, the traits class can be named "serialization_traits", its default implementation is somthing as follows:
template <typename T> struct serialization_traits { static const bool has_split_load_save = false; };
I wrote write small functions like: template<typename Archive> bool is_loading(const Archive& arch) { bool is_iarchive = boost::is_base_and_derived<boost::archive::basic_iarchive, Archive>::value; return is_iarchive; } to deal with this. It could be useful to have these in library. /Pavel
participants (2)
-
Allen Yao
-
Pavel Vozenilek