poly_function_traits.hpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // poly_function_traits.hpp
  3. // Contains specializations of poly_function_traits and as_mono_function
  4. //
  5. // Copyright 2008 Eric Niebler. Distributed under the Boost
  6. // Software License, Version 1.0. (See accompanying file
  7. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. template<typename PolyFun , typename A0>
  9. struct poly_function_traits<PolyFun, PolyFun(A0), mpl::size_t<sizeof(poly_function_t)> >
  10. {
  11. typedef typename PolyFun::template impl<const A0> function_type;
  12. typedef typename function_type::result_type result_type;
  13. };
  14. template<typename PolyFun , typename A0>
  15. struct as_mono_function_impl<PolyFun(A0), true>
  16. {
  17. typedef typename PolyFun::template impl<const A0> type;
  18. };
  19. template<typename PolyFun , typename A0>
  20. struct as_mono_function_impl<PolyFun(A0), false>
  21. {
  22. typedef PolyFun type;
  23. };
  24. template<typename PolyFun , typename A0>
  25. struct as_mono_function<PolyFun(A0)>
  26. : as_mono_function_impl<PolyFun(A0), is_poly_function<PolyFun>::value>
  27. {};
  28. template<typename PolyFun , typename A0 , typename A1>
  29. struct poly_function_traits<PolyFun, PolyFun(A0 , A1), mpl::size_t<sizeof(poly_function_t)> >
  30. {
  31. typedef typename PolyFun::template impl<const A0 , const A1> function_type;
  32. typedef typename function_type::result_type result_type;
  33. };
  34. template<typename PolyFun , typename A0 , typename A1>
  35. struct as_mono_function_impl<PolyFun(A0 , A1), true>
  36. {
  37. typedef typename PolyFun::template impl<const A0 , const A1> type;
  38. };
  39. template<typename PolyFun , typename A0 , typename A1>
  40. struct as_mono_function_impl<PolyFun(A0 , A1), false>
  41. {
  42. typedef PolyFun type;
  43. };
  44. template<typename PolyFun , typename A0 , typename A1>
  45. struct as_mono_function<PolyFun(A0 , A1)>
  46. : as_mono_function_impl<PolyFun(A0 , A1), is_poly_function<PolyFun>::value>
  47. {};
  48. template<typename PolyFun , typename A0 , typename A1 , typename A2>
  49. struct poly_function_traits<PolyFun, PolyFun(A0 , A1 , A2), mpl::size_t<sizeof(poly_function_t)> >
  50. {
  51. typedef typename PolyFun::template impl<const A0 , const A1 , const A2> function_type;
  52. typedef typename function_type::result_type result_type;
  53. };
  54. template<typename PolyFun , typename A0 , typename A1 , typename A2>
  55. struct as_mono_function_impl<PolyFun(A0 , A1 , A2), true>
  56. {
  57. typedef typename PolyFun::template impl<const A0 , const A1 , const A2> type;
  58. };
  59. template<typename PolyFun , typename A0 , typename A1 , typename A2>
  60. struct as_mono_function_impl<PolyFun(A0 , A1 , A2), false>
  61. {
  62. typedef PolyFun type;
  63. };
  64. template<typename PolyFun , typename A0 , typename A1 , typename A2>
  65. struct as_mono_function<PolyFun(A0 , A1 , A2)>
  66. : as_mono_function_impl<PolyFun(A0 , A1 , A2), is_poly_function<PolyFun>::value>
  67. {};
  68. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3>
  69. struct poly_function_traits<PolyFun, PolyFun(A0 , A1 , A2 , A3), mpl::size_t<sizeof(poly_function_t)> >
  70. {
  71. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3> function_type;
  72. typedef typename function_type::result_type result_type;
  73. };
  74. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3>
  75. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3), true>
  76. {
  77. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3> type;
  78. };
  79. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3>
  80. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3), false>
  81. {
  82. typedef PolyFun type;
  83. };
  84. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3>
  85. struct as_mono_function<PolyFun(A0 , A1 , A2 , A3)>
  86. : as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3), is_poly_function<PolyFun>::value>
  87. {};
  88. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4>
  89. struct poly_function_traits<PolyFun, PolyFun(A0 , A1 , A2 , A3 , A4), mpl::size_t<sizeof(poly_function_t)> >
  90. {
  91. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3 , const A4> function_type;
  92. typedef typename function_type::result_type result_type;
  93. };
  94. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4>
  95. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4), true>
  96. {
  97. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3 , const A4> type;
  98. };
  99. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4>
  100. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4), false>
  101. {
  102. typedef PolyFun type;
  103. };
  104. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4>
  105. struct as_mono_function<PolyFun(A0 , A1 , A2 , A3 , A4)>
  106. : as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4), is_poly_function<PolyFun>::value>
  107. {};
  108. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5>
  109. struct poly_function_traits<PolyFun, PolyFun(A0 , A1 , A2 , A3 , A4 , A5), mpl::size_t<sizeof(poly_function_t)> >
  110. {
  111. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3 , const A4 , const A5> function_type;
  112. typedef typename function_type::result_type result_type;
  113. };
  114. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5>
  115. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5), true>
  116. {
  117. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3 , const A4 , const A5> type;
  118. };
  119. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5>
  120. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5), false>
  121. {
  122. typedef PolyFun type;
  123. };
  124. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5>
  125. struct as_mono_function<PolyFun(A0 , A1 , A2 , A3 , A4 , A5)>
  126. : as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5), is_poly_function<PolyFun>::value>
  127. {};
  128. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6>
  129. struct poly_function_traits<PolyFun, PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6), mpl::size_t<sizeof(poly_function_t)> >
  130. {
  131. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6> function_type;
  132. typedef typename function_type::result_type result_type;
  133. };
  134. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6>
  135. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6), true>
  136. {
  137. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6> type;
  138. };
  139. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6>
  140. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6), false>
  141. {
  142. typedef PolyFun type;
  143. };
  144. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6>
  145. struct as_mono_function<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6)>
  146. : as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6), is_poly_function<PolyFun>::value>
  147. {};
  148. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7>
  149. struct poly_function_traits<PolyFun, PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7), mpl::size_t<sizeof(poly_function_t)> >
  150. {
  151. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7> function_type;
  152. typedef typename function_type::result_type result_type;
  153. };
  154. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7>
  155. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7), true>
  156. {
  157. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7> type;
  158. };
  159. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7>
  160. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7), false>
  161. {
  162. typedef PolyFun type;
  163. };
  164. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7>
  165. struct as_mono_function<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7)>
  166. : as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7), is_poly_function<PolyFun>::value>
  167. {};
  168. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8>
  169. struct poly_function_traits<PolyFun, PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8), mpl::size_t<sizeof(poly_function_t)> >
  170. {
  171. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 , const A8> function_type;
  172. typedef typename function_type::result_type result_type;
  173. };
  174. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8>
  175. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8), true>
  176. {
  177. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 , const A8> type;
  178. };
  179. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8>
  180. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8), false>
  181. {
  182. typedef PolyFun type;
  183. };
  184. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8>
  185. struct as_mono_function<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8)>
  186. : as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8), is_poly_function<PolyFun>::value>
  187. {};
  188. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9>
  189. struct poly_function_traits<PolyFun, PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9), mpl::size_t<sizeof(poly_function_t)> >
  190. {
  191. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 , const A8 , const A9> function_type;
  192. typedef typename function_type::result_type result_type;
  193. };
  194. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9>
  195. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9), true>
  196. {
  197. typedef typename PolyFun::template impl<const A0 , const A1 , const A2 , const A3 , const A4 , const A5 , const A6 , const A7 , const A8 , const A9> type;
  198. };
  199. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9>
  200. struct as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9), false>
  201. {
  202. typedef PolyFun type;
  203. };
  204. template<typename PolyFun , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9>
  205. struct as_mono_function<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9)>
  206. : as_mono_function_impl<PolyFun(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9), is_poly_function<PolyFun>::value>
  207. {};