has_member_function_callable_with.cpp 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2011-2014. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/intrusive for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //User define
  11. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME func0to3
  12. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 0
  13. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 3
  14. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace func0to3ns {
  15. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }
  16. #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
  17. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME func1to2
  18. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 1
  19. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 2
  20. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace func1to2ns {
  21. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }
  22. #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
  23. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME func3to3
  24. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 3
  25. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 3
  26. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace func3to3ns {
  27. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }
  28. #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
  29. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME func0to0
  30. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 0
  31. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 0
  32. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace func0to0ns {
  33. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }
  34. #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
  35. ///////////////////
  36. ///////////////////
  37. // TEST CODE
  38. ///////////////////
  39. ///////////////////
  40. struct functor
  41. {
  42. //func0to3
  43. void func0to3();
  44. void func0to3(const int&);
  45. void func0to3(const int&, const int&);
  46. void func0to3(const int&, const int&, const int&);
  47. //func1to2
  48. void func1to2(const int&);
  49. void func1to2(const int&, const int&);
  50. //func3to3
  51. void func3to3(const int&, const int&, const int&);
  52. //func0to0
  53. void func0to0();
  54. };
  55. struct functor2
  56. {
  57. void func0to3(char*);
  58. void func0to3(int, char*);
  59. void func0to3(int, char*, double);
  60. void func0to3(const int&, char*, void *);
  61. //func1to2
  62. void func1to2(char*);
  63. void func1to2(int, char*);
  64. void func1to2(int, char*, double);
  65. //func3to3
  66. void func3to3(const int&, char*, void *);
  67. };
  68. struct functor3
  69. {
  70. };
  71. struct functor4
  72. {
  73. //func0to3
  74. void func0to3(...);
  75. template<class T> void func0to3(int, const T &);
  76. template<class T> void func0to3(const T &);
  77. template<class T, class U> void func0to3(int, const T &, const U &);
  78. //func1to2
  79. template<class T> void func1to2(int, const T &);
  80. template<class T> void func1to2(const T &);
  81. template<class T, class U> void func1to2(int, const T &, const U &);
  82. //func3to3
  83. void func3to3(...);
  84. template<class T, class U> void func3to3(int, const T &, const U &);
  85. };
  86. int main()
  87. {
  88. #if !defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED)
  89. { //func0to3 0 arg
  90. using func0to3ns::has_member_function_callable_with_func0to3;
  91. int check1[ has_member_function_callable_with_func0to3<functor>::value ? 1 : -1];
  92. int check2[!has_member_function_callable_with_func0to3<functor2>::value ? 1 : -1];
  93. int check3[!has_member_function_callable_with_func0to3<functor3>::value ? 1 : -1];
  94. int check4[ has_member_function_callable_with_func0to3<functor4>::value ? 1 : -1];
  95. (void)check1;
  96. (void)check2;
  97. (void)check3;
  98. (void)check4;
  99. }
  100. { //func0to0 0 arg
  101. using func0to0ns::has_member_function_callable_with_func0to0;
  102. int check1[ has_member_function_callable_with_func0to0<functor>::value ? 1 : -1];
  103. int check2[!has_member_function_callable_with_func0to0<functor2>::value ? 1 : -1];
  104. int check3[!has_member_function_callable_with_func0to0<functor3>::value ? 1 : -1];
  105. (void)check1;
  106. (void)check2;
  107. (void)check3;
  108. }
  109. #endif
  110. { //func0to3 1arg
  111. using func0to3ns::has_member_function_callable_with_func0to3;
  112. int check1[ has_member_function_callable_with_func0to3<functor, int>::value ? 1 : -1];
  113. int check2[!has_member_function_callable_with_func0to3<functor, char*>::value ? 1 : -1];
  114. int check3[!has_member_function_callable_with_func0to3<functor2, int>::value ? 1 : -1];
  115. int check4[ has_member_function_callable_with_func0to3<functor2, char*>::value ? 1 : -1];
  116. int check5[!has_member_function_callable_with_func0to3<functor3, int>::value ? 1 : -1];
  117. int check6[!has_member_function_callable_with_func0to3<functor3, char*>::value ? 1 : -1];
  118. int check7[ has_member_function_callable_with_func0to3<functor4, int>::value ? 1 : -1];
  119. int check8[ has_member_function_callable_with_func0to3<functor4, char*>::value ? 1 : -1];
  120. (void)check1;
  121. (void)check2;
  122. (void)check3;
  123. (void)check4;
  124. (void)check5;
  125. (void)check6;
  126. (void)check7;
  127. (void)check8;
  128. }
  129. { //func1to2 1arg
  130. using func1to2ns::has_member_function_callable_with_func1to2;
  131. int check1[ has_member_function_callable_with_func1to2<functor, int>::value ? 1 : -1];
  132. int check2[!has_member_function_callable_with_func1to2<functor, char*>::value ? 1 : -1];
  133. int check3[!has_member_function_callable_with_func1to2<functor2, int>::value ? 1 : -1];
  134. int check4[ has_member_function_callable_with_func1to2<functor2, char*>::value ? 1 : -1];
  135. int check5[!has_member_function_callable_with_func1to2<functor3, int>::value ? 1 : -1];
  136. int check6[!has_member_function_callable_with_func1to2<functor3, char*>::value ? 1 : -1];
  137. int check7[ has_member_function_callable_with_func1to2<functor4, int>::value ? 1 : -1];
  138. int check8[ has_member_function_callable_with_func1to2<functor4, char*>::value ? 1 : -1];
  139. (void)check1;
  140. (void)check2;
  141. (void)check3;
  142. (void)check4;
  143. (void)check5;
  144. (void)check6;
  145. (void)check7;
  146. (void)check8;
  147. }
  148. { //func0to3 2arg
  149. using func0to3ns::has_member_function_callable_with_func0to3;
  150. int check1[ has_member_function_callable_with_func0to3<functor, int, int>::value ? 1 : -1];
  151. int check2[!has_member_function_callable_with_func0to3<functor, int, char*>::value ? 1 : -1];
  152. int check3[!has_member_function_callable_with_func0to3<functor2, int, int>::value ? 1 : -1];
  153. int check4[ has_member_function_callable_with_func0to3<functor2, int, char*>::value ? 1 : -1];
  154. int check5[!has_member_function_callable_with_func0to3<functor3, int, int>::value ? 1 : -1];
  155. int check6[!has_member_function_callable_with_func0to3<functor3, int, char*>::value ? 1 : -1];
  156. int check7[ has_member_function_callable_with_func0to3<functor4, int, char*>::value ? 1 : -1];
  157. (void)check1;
  158. (void)check2;
  159. (void)check3;
  160. (void)check4;
  161. (void)check5;
  162. (void)check6;
  163. (void)check7;
  164. }
  165. { //func1to2 2arg
  166. using func1to2ns::has_member_function_callable_with_func1to2;
  167. int check1[ has_member_function_callable_with_func1to2<functor, int, int>::value ? 1 : -1];
  168. int check2[!has_member_function_callable_with_func1to2<functor, int, char*>::value ? 1 : -1];
  169. int check3[!has_member_function_callable_with_func1to2<functor2, int, int>::value ? 1 : -1];
  170. int check4[ has_member_function_callable_with_func1to2<functor2, int, char*>::value ? 1 : -1];
  171. int check5[!has_member_function_callable_with_func1to2<functor3, int, int>::value ? 1 : -1];
  172. int check6[!has_member_function_callable_with_func1to2<functor3, int, char*>::value ? 1 : -1];
  173. int check7[ has_member_function_callable_with_func1to2<functor4, int, char*>::value ? 1 : -1];
  174. (void)check1;
  175. (void)check2;
  176. (void)check3;
  177. (void)check4;
  178. (void)check5;
  179. (void)check6;
  180. (void)check7;
  181. }
  182. { //func0to3 3arg
  183. using func0to3ns::has_member_function_callable_with_func0to3;
  184. int check1[ has_member_function_callable_with_func0to3<functor, int, int, int>::value ? 1 : -1];
  185. int check2[!has_member_function_callable_with_func0to3<functor, int, char*, int>::value ? 1 : -1];
  186. int check3[!has_member_function_callable_with_func0to3<functor2, int, int, int>::value ? 1 : -1];
  187. int check4[ has_member_function_callable_with_func0to3<functor2, int, char*, void*>::value ? 1 : -1];
  188. int check5[!has_member_function_callable_with_func0to3<functor3, int, int, int>::value ? 1 : -1];
  189. int check6[!has_member_function_callable_with_func0to3<functor3, int, char*, void*>::value ? 1 : -1];
  190. int check7[ has_member_function_callable_with_func0to3<functor4, int, char*, int>::value ? 1 : -1];
  191. (void)check1;
  192. (void)check2;
  193. (void)check3;
  194. (void)check4;
  195. (void)check5;
  196. (void)check6;
  197. (void)check7;
  198. }
  199. { //func3to3 3arg
  200. using func3to3ns::has_member_function_callable_with_func3to3;
  201. int check1[ has_member_function_callable_with_func3to3<functor, int, int, int>::value ? 1 : -1];
  202. int check2[!has_member_function_callable_with_func3to3<functor, int, char*, int>::value ? 1 : -1];
  203. int check3[!has_member_function_callable_with_func3to3<functor2, int, int, int>::value ? 1 : -1];
  204. int check4[ has_member_function_callable_with_func3to3<functor2, int, char*, void*>::value ? 1 : -1];
  205. int check5[!has_member_function_callable_with_func3to3<functor3, int, int, int>::value ? 1 : -1];
  206. int check6[!has_member_function_callable_with_func3to3<functor3, int, char*, void*>::value ? 1 : -1];
  207. int check7[ has_member_function_callable_with_func3to3<functor4, int, char*, int>::value ? 1 : -1];
  208. (void)check1;
  209. (void)check2;
  210. (void)check3;
  211. (void)check4;
  212. (void)check5;
  213. (void)check6;
  214. (void)check7;
  215. }
  216. return 0;
  217. }