mirror of
https://github.com/USCiLab/cereal.git
synced 2025-10-18 01:45:52 +02:00
adding support for more stl types
This commit is contained in:
33
binary_archive/list.hpp
Normal file
33
binary_archive/list.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef CEREAL_BINARY_ARCHIVE_LIST_HPP_
|
||||
#define CEREAL_BINARY_ARCHIVE_LIST_HPP_
|
||||
|
||||
#include <cereal/binary_archive/binary_archive.hpp>
|
||||
#include <list>
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
//! Saving for std::list all other types to binary
|
||||
template <class T, size_t A>
|
||||
void save( BinaryOutputArchive & ar, std::list<T, A> const & list )
|
||||
{
|
||||
ar & list.size();
|
||||
|
||||
for( const auto & i : list )
|
||||
ar & i;
|
||||
}
|
||||
|
||||
//! Loading for std::list all other types to binary
|
||||
template <class T, size_t A>
|
||||
void load( BinaryInputArchive & ar, std::list<T, A> & list )
|
||||
{
|
||||
size_t size;
|
||||
ar & size;
|
||||
|
||||
list.resize( size );
|
||||
|
||||
for( auto & i : list )
|
||||
ar & i;
|
||||
}
|
||||
} // namespace cereal
|
||||
|
||||
#endif // CEREAL_BINARY_ARCHIVE_LIST_HPP_
|
||||
Reference in New Issue
Block a user