diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..80c617cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# Compiled Object files +*.slo +*.lo +*.o + +# Compiled Dynamic libraries +*.so +*.dylib + +# Compiled Static libraries +*.lai +*.la +*.a + +out.txt +ptr.txt +test +test.txt +unittests +boost_serialize +arr.txt diff --git a/binary_archive/deque.hpp b/binary_archive/deque.hpp index 283193b9..c7878abb 100644 --- a/binary_archive/deque.hpp +++ b/binary_archive/deque.hpp @@ -16,7 +16,7 @@ namespace cereal ar & i; } - //! Loading for std::deque all other types to binary + //! Loading for std::deque to binary template void load( BinaryInputArchive & ar, std::deque & deque ) { diff --git a/binary_archive/list.hpp b/binary_archive/list.hpp index 1b95ee1b..eeadaa3a 100644 --- a/binary_archive/list.hpp +++ b/binary_archive/list.hpp @@ -6,7 +6,7 @@ namespace cereal { - //! Saving for std::list all other types to binary + //! Saving for std::list to binary template void save( BinaryOutputArchive & ar, std::list const & list ) { @@ -16,7 +16,7 @@ namespace cereal ar & i; } - //! Loading for std::list all other types to binary + //! Loading for std::list to binary template void load( BinaryInputArchive & ar, std::list & list ) { diff --git a/binary_archive/queue.hpp b/binary_archive/queue.hpp new file mode 100644 index 00000000..34511b66 --- /dev/null +++ b/binary_archive/queue.hpp @@ -0,0 +1,75 @@ +#ifndef CEREAL_BINARY_ARCHIVE_QUEUE_HPP_ +#define CEREAL_BINARY_ARCHIVE_QUEUE_HPP_ + +#include +#include + +namespace cereal +{ + namespace queue_detail + { + //! Allows access to the protected container in queue + template + C const & container( std::queue const & queue ) + { + struct H : public std::queue + { + static C const & get( std::queue const & q ) + { + return q.*(&H::c); + } + }; + + return H::get( queue ); + } + + //! Allows access to the protected container in priority queue + template + C const & container( std::priority_queue const & priority_queue ) + { + struct H : public std::priority_queue + { + static C const & get( std::priority_queue const & pq ) + { + return pq.*(&H::c); + } + }; + + return H::get( priority_queue ); + } + } + + //! Saving for std::queue to binary + template + void save( BinaryOutputArchive & ar, std::queue const & queue ) + { + ar & queue_detail::container( queue ); + } + + //! Loading for std::queue to binary + template + void load( BinaryInputArchive & ar, std::queue & queue ) + { + C container; + ar & container; + queue = std::queue( std::move( container ) ); + } + + //! Saving for std::priority_queue to binary + template + void save( BinaryOutputArchive & ar, std::priority_queue const & priority_queue ) + { + ar & queue_detail::container( priority_queue ); + } + + //! Loading for std::priority_queue to binary + template + void load( BinaryInputArchive & ar, std::priority_queue & priority_queue ) + { + C container; + ar & container; + priority_queue = std::priority_queue( std::move( container ) ); + } +} // namespace cereal + +#endif // CEREAL_BINARY_ARCHIVE_QUEUE_HPP_ diff --git a/binary_archive/stack.hpp b/binary_archive/stack.hpp new file mode 100644 index 00000000..d831bfde --- /dev/null +++ b/binary_archive/stack.hpp @@ -0,0 +1,44 @@ +#ifndef CEREAL_BINARY_ARCHIVE_STACK_HPP_ +#define CEREAL_BINARY_ARCHIVE_STACK_HPP_ + +#include +#include + +namespace cereal +{ + namespace stack_detail + { + //! Allows access to the protected container in stack + template + C const & container( std::stack const & stack ) + { + struct H : public std::stack + { + static C const & get( std::stack const & s ) + { + return s.*(&H::c); + } + }; + + return H::get( stack ); + } + } + + //! Saving for std::stack to binary + template + void save( BinaryOutputArchive & ar, std::stack const & stack ) + { + ar & stack_detail::container( stack ); + } + + //! Loading for std::stack to binary + template + void load( BinaryInputArchive & ar, std::stack & stack ) + { + C container; + ar & container; + stack = std::stack( std::move( container ) ); + } +} // namespace cereal + +#endif // CEREAL_BINARY_ARCHIVE_STACK_HPP_