Skip to content

Commit

Permalink
Remove serialization support from Boost.Unordered containers
Browse files Browse the repository at this point in the history
Unordered now supports its Serialization functions so the headers just need to be updated to keep backwards compatibility
  • Loading branch information
cmazakas committed Sep 11, 2023
1 parent 61a2b12 commit f284822
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 534 deletions.
2 changes: 0 additions & 2 deletions CMake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ archive_test(test_list A)
archive_test(test_list_ptrs A)

archive_test(test_map A)
archive_test(test_map_boost_unordered A)
CHECK_INCLUDE_FILE_CXX(hash_map HASH_MAP_FOUND)
if(HASH_MAP_FOUND)
archive_test(test_map_hashed A)
Expand Down Expand Up @@ -308,7 +307,6 @@ archive_test(test_recursion A)
archive_test(test_registered)

archive_test(test_set A)
archive_test(test_set_boost_unordered A)
CHECK_INCLUDE_FILE_CXX(hash_set HASH_SET_FOUND)
if(HASH_SET_FOUND)
archive_test(test_set_hashed A)
Expand Down
142 changes: 5 additions & 137 deletions include/boost/serialization/boost_unordered_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,143 +18,11 @@

// See http://www.boost.org for updates, documentation, and revision history.

#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>

#include <boost/unordered_map.hpp>

#include <boost/serialization/utility.hpp>
#include <boost/serialization/unordered_collections_save_imp.hpp>
#include <boost/serialization/unordered_collections_load_imp.hpp>
#include <boost/serialization/archive_input_unordered_map.hpp>
#include <boost/serialization/split_free.hpp>

namespace boost {
namespace serialization {

template<
class Archive,
class Key,
class T,
class HashFcn,
class EqualKey,
class Allocator
>
inline void save(
Archive & ar,
const boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator> &t,
const unsigned int /*file_version*/
){
boost::serialization::stl::save_unordered_collection<
Archive,
boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator>
>(ar, t);
}

template<
class Archive,
class Key,
class T,
class HashFcn,
class EqualKey,
class Allocator
>
inline void load(
Archive & ar,
boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator> &t,
const unsigned int /*file_version*/
){
boost::serialization::stl::load_unordered_collection<
Archive,
boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator>,
boost::serialization::stl::archive_input_unordered_map<
Archive,
boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator>
>
>(ar, t);
}

// split non-intrusive serialization function member into separate
// non intrusive save/load member functions
template<
class Archive,
class Key,
class T,
class HashFcn,
class EqualKey,
class Allocator
>
inline void serialize(
Archive & ar,
boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator> &t,
const unsigned int file_version
){
boost::serialization::split_free(ar, t, file_version);
}

// unordered_multimap
template<
class Archive,
class Key,
class HashFcn,
class T,
class EqualKey,
class Allocator
>
inline void save(
Archive & ar,
const boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator> &t,
const unsigned int /*file_version*/
){
boost::serialization::stl::save_unordered_collection<
Archive,
boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator>
>(ar, t);
}

template<
class Archive,
class Key,
class T,
class HashFcn,
class EqualKey,
class Allocator
>
inline void load(
Archive & ar,
boost::unordered_multimap<
Key, T, HashFcn, EqualKey, Allocator
> &t,
const unsigned int /*file_version*/
){
boost::serialization::stl::load_unordered_collection<
Archive,
boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator>,
boost::serialization::stl::archive_input_unordered_multimap<
Archive,
boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator>
>
>(ar, t);
}

// split non-intrusive serialization function member into separate
// non intrusive save/load member functions
template<
class Archive,
class Key,
class T,
class HashFcn,
class EqualKey,
class Allocator
>
inline void serialize(
Archive & ar,
boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator> &t,
const unsigned int file_version
){
boost::serialization::split_free(ar, t, file_version);
}

} // namespace serialization
} // namespace boost
BOOST_PRAGMA_MESSAGE(
"Boost.Unordered now provides its own Serialization support. "
"This header is no longer necessary and is now deprecated."
)

#endif // BOOST_SERIALIZATION_BOOST_SERIALIZATION_UNORDERED_MAP_HPP
133 changes: 5 additions & 128 deletions include/boost/serialization/boost_unordered_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,134 +17,11 @@

// See http://www.boost.org for updates, documentation, and revision history.

#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>

#include <boost/unordered_set.hpp>

#include <boost/serialization/unordered_collections_save_imp.hpp>
#include <boost/serialization/unordered_collections_load_imp.hpp>
#include <boost/serialization/archive_input_unordered_set.hpp>
#include <boost/serialization/split_free.hpp>

namespace boost {
namespace serialization {

template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
>
inline void save(
Archive & ar,
const boost::unordered_set<Key, HashFcn, EqualKey, Allocator> &t,
const unsigned int /*file_version*/
){
boost::serialization::stl::save_unordered_collection<
Archive,
boost::unordered_set<Key, HashFcn, EqualKey, Allocator>
>(ar, t);
}

template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
>
inline void load(
Archive & ar,
boost::unordered_set<Key, HashFcn, EqualKey, Allocator> &t,
const unsigned int /*file_version*/
){
boost::serialization::stl::load_unordered_collection<
Archive,
boost::unordered_set<Key, HashFcn, EqualKey, Allocator>,
boost::serialization::stl::archive_input_unordered_set<
Archive,
boost::unordered_set<Key, HashFcn, EqualKey, Allocator>
>
>(ar, t);
}

// split non-intrusive serialization function member into separate
// non intrusive save/load member functions
template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
>
inline void serialize(
Archive & ar,
boost::unordered_set<Key, HashFcn, EqualKey, Allocator> &t,
const unsigned int file_version
){
boost::serialization::split_free(ar, t, file_version);
}

// unordered_multiset
template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
>
inline void save(
Archive & ar,
const boost::unordered_multiset<Key, HashFcn, EqualKey, Allocator> &t,
const unsigned int /*file_version*/
){
boost::serialization::stl::save_unordered_collection<
Archive,
boost::unordered_multiset<Key, HashFcn, EqualKey, Allocator>
>(ar, t);
}

template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
>
inline void load(
Archive & ar,
boost::unordered_multiset<Key, HashFcn, EqualKey, Allocator> &t,
const unsigned int /*file_version*/
){
boost::serialization::stl::load_unordered_collection<
Archive,
boost::unordered_multiset<Key, HashFcn, EqualKey, Allocator>,
boost::serialization::stl::archive_input_unordered_multiset<
Archive,
boost::unordered_multiset<Key, HashFcn, EqualKey, Allocator>
>
>(ar, t);
}

// split non-intrusive serialization function member into separate
// non intrusive save/load member functions
template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
>
inline void serialize(
Archive & ar,
boost::unordered_multiset<Key, HashFcn, EqualKey, Allocator> &t,
const unsigned int file_version
){
boost::serialization::split_free(ar, t, file_version);
}

} // namespace serialization
} // namespace boost
BOOST_PRAGMA_MESSAGE(
"Boost.Unordered now provides its own Serialization support. "
"This header is no longer necessary and is now deprecated."
)

#endif // BOOST_SERIALIZATION_BOOST_UNORDERED_SET_HPP
2 changes: 0 additions & 2 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ test-suite "serialization" :
[ test-bsl-run_files test_map : A ]
[ test-bsl-run_files test_map_hashed : A : : [ requires hash ] ] # BOOST_HAS_HASH
[ test-bsl-run_files test_map_unordered : A : : [ requires cxx11_hdr_unordered_map ] ] # BOOST_NO_CXX11_HDR_UNORDERED_MAP
[ test-bsl-run_files test_map_boost_unordered : A ]
[ test-bsl-run_files test_mi ]
[ test-bsl-run_files test_multiple_ptrs : A ]
[ test-bsl-run_files test_multiple_inheritance ]
Expand All @@ -100,7 +99,6 @@ test-suite "serialization" :
[ test-bsl-run_files test_set : A ]
[ test-bsl-run_files test_set_hashed : A : : [ requires hash ] ] # BOOST_HAS_HASH
[ test-bsl-run_files test_set_unordered : A : : [ requires cxx11_hdr_unordered_set ] ] # BOOST_NO_CXX11_HDR_UNORDERED_SET
[ test-bsl-run_files test_set_boost_unordered : A ]
[ test-bsl-run_files test_simple_class : A ]
[ test-bsl-run_files test_simple_class_ptr : A ]
[ test-bsl-run_files test_slist : A : : [ requires slist ] ] # BOOST_HAS_SLIST ]
Expand Down
Loading

0 comments on commit f284822

Please sign in to comment.