|
Ublas : |
From: Neal Becker (ndbecker2_at_[hidden])
Date: 2007-01-02 21:44:54
Here is what I am using for ublas::vector:
namespace boost {
namespace serialization {
template<class T>
struct implementation_level<ublas::vector<T> >
{
typedef mpl::integral_c_tag tag;
// typedef mpl::int_<primitive_type> type;
typedef mpl::int_<object_serializable> type;
BOOST_STATIC_CONSTANT(
int,
value = implementation_level::type::value
);
};
}
}
template<class Archive, class U>
inline void save (Archive &ar, const ublas::vector<U> &v, const unsigned int) {
unsigned int count = v.size();
ar << BOOST_SERIALIZATION_NVP (count);
typename ublas::vector<U>::const_iterator it = v.begin();
while (count-- > 0) {
ar << boost::serialization::make_nvp ("item", *it++);
}
}
template<class Archive, class U>
inline void load (Archive &ar, ublas::vector<U> &v, const unsigned int) {
unsigned int count;
ar >> BOOST_SERIALIZATION_NVP (count);
v.resize (count);
typename ublas::vector<U>::iterator it = v.begin();
while (count-- > 0) {
ar >> boost::serialization::make_nvp ("item", *it++);
}
}
namespace boost { namespace serialization {
template<class Archive, class U>
inline void serialize (Archive &ar, ublas::vector<U>& v, const unsigned int file_version) {
boost::serialization::split_free (ar, v, file_version);
}
}
}