Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JossWhittle committed Oct 27, 2016
1 parent 911334c commit 600ece6
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions MEL_deepcopy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,13 @@ namespace MEL {
template<typename T, typename R = void>
using enable_if_not_deep_not_pointer = typename std::enable_if<!HasDeepCopyMethod<T>::Has && !std::is_pointer<T>::value, R>::type;

template <typename T>
using is_vector = typename std::is_same<T, std::vector<typename T::value_type, typename T::allocator_type>>;
template <typename T>
using is_list = typename std::is_same<T, std::list<typename T::value_type, typename T::allocator_type>>;
template<typename T> struct is_vector : public std::false_type {};
template<typename T, typename A>
struct is_vector<std::vector<T, A>> : public std::true_type{};

template<typename T> struct is_list : public std::false_type {};
template<typename T, typename A>
struct is_list<std::list<T, A>> : public std::true_type{};
//template <typename T>
//using is_string = typename std::is_same<T, std::string>;

Expand Down Expand Up @@ -531,20 +534,20 @@ namespace MEL {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// STL

inline void packSTL(std::string &obj) {
int len;
if (TRANSPORT_METHOD::SOURCE) {
len = obj.size();
transport(len);
}
else {
transport(len);
new (&obj) std::string(len, ' ');
}

char *p = &obj[0];
if (len > 0) transport(p, len);
};
inline void packSTL(std::string &obj) {
int len;
if (TRANSPORT_METHOD::SOURCE) {
len = obj.size();
transport(len);
}
else {
transport(len);
new (&obj) std::string(len, ' ');
}

char *p = &obj[0];
if (len > 0) transport(p, len);
};

template<typename T>
inline enable_if_not_deep<T> packSTL(std::vector<T> &obj) {
Expand Down Expand Up @@ -762,16 +765,16 @@ namespace MEL {
return *this;
};

template<typename T>
template<typename T>
inline Message<TRANSPORT_METHOD, HASH_MAP>& operator&(T &obj) {
packVar(obj);
return *this;
};

inline Message<TRANSPORT_METHOD, HASH_MAP>& operator&(std::string &obj) {
packSTL(obj);
return *this;
};
inline Message<TRANSPORT_METHOD, HASH_MAP>& operator&(std::string &obj) {
packSTL(obj);
return *this;
};
};

#define TEMPLATE_STL template<typename S, typename HASH_MAP = MEL::Deep::PointerHashMap>
Expand Down Expand Up @@ -926,14 +929,14 @@ namespace MEL {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pointer

TEMPLATE_P
TEMPLATE_P
inline enable_if_pointer<P> Send(const P &ptr, const int dst, const int tag, const Comm &comm) {
Send((P) ptr, dst, tag, comm);
Send((P) ptr, dst, tag, comm);
};

TEMPLATE_P
inline enable_if_pointer<P> Send(P &ptr, const int dst, const int tag, const Comm &comm) {
Message<TransportSend, HASH_MAP> msg(dst, tag, comm);
Message<TransportSend, HASH_MAP> msg(dst, tag, comm);
msg.packRootPtr(ptr);
};

Expand Down Expand Up @@ -2275,10 +2278,10 @@ namespace MEL {
MEL::Deep::BufferedFileWrite(ptr, file, MEL::Deep::BufferSize(ptr));
};

TEMPLATE_P
inline enable_if_pointer<P> BufferedFileWrite_FUCK(P &ptr, std::ofstream &file) {
MEL::Deep::BufferedFileWrite(ptr, file, MEL::Deep::BufferSize(ptr));
};
TEMPLATE_P
inline enable_if_pointer<P> BufferedFileWrite_FUCK(P &ptr, std::ofstream &file) {
MEL::Deep::BufferedFileWrite(ptr, file, MEL::Deep::BufferSize(ptr));
};

TEMPLATE_P_F(TransportBufferWrite)
inline enable_if_pointer<P> BufferedFileWrite(P &ptr, std::ofstream &file) {
Expand Down

0 comments on commit 600ece6

Please sign in to comment.