Commit ccbba8e2 authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

Merge branch 'master' of bitbucket.org:mdorier/thallium

parents 5cef3fbd 6d68f413
...@@ -11,15 +11,16 @@ class point { ...@@ -11,15 +11,16 @@ class point {
point(double a=0.0, double b=0.0, double c=0.0) point(double a=0.0, double b=0.0, double c=0.0)
: x(a), y(b), z(c) {} : x(a), y(b), z(c) {}
template<typename A> template<typename A> friend void serialize(A& ar, point& p);
void serialize(A& ar) {
ar & x;
ar & y;
ar & z;
}
double operator*(const point& p) const { double operator*(const point& p) const {
return p.x * x + p.y * y + p.z * z; 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> { ...@@ -120,7 +120,7 @@ struct serializer<A,T,false> {
* Generic serialize method calling apply on a serializer. * Generic serialize method calling apply on a serializer.
*/ */
template<class A, typename T> 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)); serializer<A,T,has_serialize_method<A,T>::value>::apply(ar,std::forward<T>(t));
} }
...@@ -141,7 +141,7 @@ struct saver<A,T,true> { ...@@ -141,7 +141,7 @@ struct saver<A,T,true> {
template<class A, typename T> template<class A, typename T>
struct saver<A,T,false> { struct saver<A,T,false> {
static void apply(A& ar, T& t) { 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) { ...@@ -154,12 +154,7 @@ inline void save(A& ar, T& t) {
} }
template<class A, typename T> template<class A, typename T>
inline void save(A& ar, T&& t) { inline void save(A& ar, const T& t) {
save(ar, t);
}
template<class A, typename T>
inline void save(A& ar, const T&& t) {
save(ar, const_cast<T&>(t)); save(ar, const_cast<T&>(t));
} }
...@@ -180,7 +175,7 @@ struct loader<A,T,true> { ...@@ -180,7 +175,7 @@ struct loader<A,T,true> {
template<class A, typename T> template<class A, typename T>
struct loader<A,T,false> { struct loader<A,T,false> {
static void apply(A& ar, T& t) { 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) { ...@@ -192,11 +187,6 @@ inline void load(A& ar, T& t) {
loader<A,T,has_load_method<A,T>::value>::apply(ar,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 * Helper function that serializes an arbitrary number of
* objects passed as arguments. * 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