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/forward_list.hpp
Normal file
33
binary_archive/forward_list.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef CEREAL_BINARY_ARCHIVE_FORWARD_LIST_HPP_
|
||||
#define CEREAL_BINARY_ARCHIVE_FORWARD_LIST_HPP_
|
||||
|
||||
#include <cereal/binary_archive/binary_archive.hpp>
|
||||
#include <forward_list>
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
//! Saving for std::forward_list all other types to binary
|
||||
template <class T, size_t A>
|
||||
void save( BinaryOutputArchive & ar, std::forward_list<T, A> const & forward_list )
|
||||
{
|
||||
ar & forward_list.size();
|
||||
|
||||
for( const auto & i : forward_list )
|
||||
ar & i;
|
||||
}
|
||||
|
||||
//! Loading for std::forward_list all other types to binary
|
||||
template <class T, size_t A>
|
||||
void load( BinaryInputArchive & ar, std::forward_list<T, A> & forward_list )
|
||||
{
|
||||
size_t size;
|
||||
ar & size;
|
||||
|
||||
forward_list.resize( size );
|
||||
|
||||
for( auto & i : forward_list )
|
||||
ar & i;
|
||||
}
|
||||
} // namespace cereal
|
||||
|
||||
#endif // CEREAL_BINARY_ARCHIVE_FORWARD_LIST_HPP_
|
||||
Reference in New Issue
Block a user