Arduino Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
has_serialize.hpp
Go to the documentation of this file.
1 // Author: Mario S. Könz <mskoenz@gmx.net>
2 // Date: 02.07.2013 17:20:07 EDT
3 // File: has_serialize.hpp
4 
5 /* This program is free software. It comes without any warranty, to
6  * the extent permitted by applicable law. You can redistribute it
7  * and/or modify it under the terms of the Do What The Fuck You Want
8  * To Public License, Version 2, as published by Sam Hocevar. See
9  * http://www.wtfpl.net/ or COPYING for more details. */
10 
11 #ifndef __HAS_SERIALIZE_HEADER
12 #define __HAS_SERIALIZE_HEADER
13 
14 namespace util {
15  //------------------- checks if T is a class and has a template method called serialize -------------------
16  template<typename T, bool is_a_class>
20  template<typename U> void operator &(U & u);
21  };
22  template<void(T::*)(archive_proto_type &)> struct helper {typedef char type;};
23 
24  template<typename U> static char check(typename helper<&U::template serialize<archive_proto_type>>::type);
25  template<typename U> static double check(...);
26 
27  enum { value = (sizeof(char) == sizeof(check<T>(0))) };
28  };
29  template<typename T>
30  struct has_serialize_impl<T, false> { //if T is not a class it cannot have serialize
31  enum { value = false };
32  };
33  template<typename T>
34  struct has_serialize {
36  };
37 }//end namespace util
38 #endif //__HAS_SERIALIZE_HEADER
Definition: has_serialize.hpp:27
Definition: has_serialize.hpp:18
static archive_enum const type
Definition: has_serialize.hpp:19
archive_enum
Definition: archive_enum.hpp:14
Definition: has_serialize.hpp:17
char type
Definition: has_serialize.hpp:22
static char check(typename helper<&U::template serialize< archive_proto_type >>::type)
Definition: has_serialize.hpp:35
Definition: has_serialize.hpp:34
Definition: has_serialize.hpp:22