Arduino Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
has_i2c_read_write.hpp
Go to the documentation of this file.
1 // Author: Mario S. Könz <mskoenz@gmx.net>
2 // Date: 07.11.2013 21:42:45 CET
3 // File: has_i2c_read_write.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_I2C_READ_WRITE_HEADER
12 #define __HAS_I2C_READ_WRITE_HEADER
13 
14 namespace util {
15  //------------------- checks if T is a class and has a method called i2c_read -------------------
16  template<typename T, bool is_a_class>
18 
19  template<void(T::*)(int)> struct helper {typedef char type;};
20 
21  template<typename U> static char check(typename helper<&U::i2c_read>::type);
22  template<typename U> static double check(...);
23 
24  enum { value = (sizeof(char) == sizeof(check<T>(0))) };
25  };
26  template<typename T>
27  struct has_i2c_read_impl<T, false> { //if T is not a class it cannot have print
28  enum { value = false };
29  };
30  template<typename T>
31  struct has_i2c_read {
33  };
34  //------------------- checks if T is a class and has a method called i2c_write -------------------
35  template<typename T, bool is_a_class>
37 
38  template<void(T::*)()> struct helper {typedef char type;};
39 
40  template<typename U> static char check(typename helper<&U::i2c_write>::type);
41  template<typename U> static double check(...);
42 
43  enum { value = (sizeof(char) == sizeof(check<T>(0))) };
44  };
45  template<typename T>
46  struct has_i2c_write_impl<T, false> { //if T is not a class it cannot have print
47  enum { value = false };
48  };
49  template<typename T>
50  struct has_i2c_write {
52  };
53 }//end namespace util
54 
55 #endif //__HAS_I2C_READ_WRITE_HEADER
Definition: has_i2c_read_write.hpp:19
Definition: has_i2c_read_write.hpp:51
static char check(typename helper<&U::i2c_write >::type)
Definition: has_i2c_read_write.hpp:50
Definition: has_i2c_read_write.hpp:32
char type
Definition: has_i2c_read_write.hpp:19
Definition: has_i2c_read_write.hpp:43
static char check(typename helper<&U::i2c_read >::type)
Definition: has_i2c_read_write.hpp:17
Definition: has_i2c_read_write.hpp:36
char type
Definition: has_i2c_read_write.hpp:38
Definition: has_i2c_read_write.hpp:38
Definition: has_i2c_read_write.hpp:31
Definition: has_i2c_read_write.hpp:24