list.hpp 489 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#ifndef THALLIUM_LIST_SERIALIZATION_H
#define THALLIUM_LIST_SERIALIZATION_H

#include <list>

namespace thallium {

template<class A, typename T, typename Alloc>
void save(A& ar, std::list<T,Alloc>& l) {
	size_t size = l.size();
	ar.write(&size);
	for(auto& item : l) {
		ar & item;
	}
}

template<class A, typename T, typename Alloc>
void load(A& ar, std::list<T,Alloc>& l) {
	size_t size;
	l.clear();
	ar.read(&size);
	l.resize(size);
	for(auto& item : l) {
		ar & item;
	}
}

}

#endif