Commit 6d68f413 authored by Matthieu Dorier's avatar Matthieu Dorier

corrected SFINAE problem in serialization

parent cebb346a
......@@ -11,15 +11,16 @@ class point {
point(double a=0.0, double b=0.0, double c=0.0)
: x(a), y(b), z(c) {}
template<typename A>
void serialize(A& ar) {
ar & x;
ar & y;
ar & z;
}
template<typename A> friend void serialize(A& ar, point& p);
double operator*(const point& p) const {
return p.x * x + p.y * y + p.z * z;
}
};
template<typename A>
void serialize(A& ar, point& p) {
ar & p.x;
ar & p.y;
ar & p.z;
}
......@@ -120,7 +120,7 @@ struct serializer<A,T,false> {
* Generic serialize method calling apply on a serializer.
*/
template<class A, typename T>
void serialize(A& ar, T&& t) {
void serialize(A& ar, T& t) {
serializer<A,T,has_serialize_method<A,T>::value>::apply(ar,std::forward<T>(t));
}
......@@ -141,7 +141,7 @@ struct saver<A,T,true> {
template<class A, typename T>
struct saver<A,T,false> {
static void apply(A& ar, T& t) {
serialize(ar,std::forward<T>(t));
serialize(ar,t);
}
};
......@@ -154,12 +154,7 @@ inline void save(A& ar, T& t) {
}
template<class A, typename T>
inline void save(A& ar, T&& t) {
save(ar, t);
}
template<class A, typename T>
inline void save(A& ar, const T&& t) {
inline void save(A& ar, const T& t) {
save(ar, const_cast<T&>(t));
}
......@@ -180,7 +175,7 @@ struct loader<A,T,true> {
template<class A, typename T>
struct loader<A,T,false> {
static void apply(A& ar, T& t) {
serialize(ar,std::forward<T>(t));
serialize(ar,t);
}
};
......@@ -192,11 +187,6 @@ inline void load(A& ar, T& t) {
loader<A,T,has_load_method<A,T>::value>::apply(ar,t);
}
template<class A, typename T>
inline void load(A& ar, T&& t) {
load(ar, t);
}
/**
* Helper function that serializes an arbitrary number of
* objects passed as arguments.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment