funop.hpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // funop.hpp
  3. // Contains definition of funop[n]\<\> class template.
  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 Expr, typename Domain >
  9. struct funop0
  10. {
  11. typedef typename proto::base_expr<
  12. Domain
  13. , tag::function
  14. , list1<
  15. Expr &
  16. >
  17. >::type type;
  18. BOOST_FORCEINLINE
  19. static type const call(
  20. Expr &e
  21. )
  22. {
  23. type that = {
  24. e
  25. };
  26. return that;
  27. }
  28. };
  29. template<typename Expr , typename This, typename Domain>
  30. struct funop<Expr(), This, Domain>
  31. : funop0<
  32. typename detail::same_cv<Expr, This>::type
  33. , Domain
  34. >
  35. {};
  36. template<typename Expr, typename Domain , typename A0>
  37. struct funop1
  38. {
  39. typedef typename proto::base_expr<
  40. Domain
  41. , tag::function
  42. , list2<
  43. Expr &
  44. , typename proto::result_of::as_child<A0, Domain>::type
  45. >
  46. >::type type;
  47. BOOST_FORCEINLINE
  48. static type const call(
  49. Expr &e
  50. , A0 &a0
  51. )
  52. {
  53. type that = {
  54. e
  55. , proto::as_child<Domain>(a0)
  56. };
  57. return that;
  58. }
  59. };
  60. template<typename Expr , typename A0, typename This, typename Domain>
  61. struct funop<Expr(A0), This, Domain>
  62. : funop1<
  63. typename detail::same_cv<Expr, This>::type
  64. , Domain
  65. , typename remove_reference<A0 >::type
  66. >
  67. {};
  68. template<typename Expr, typename Domain , typename A0 , typename A1>
  69. struct funop2
  70. {
  71. typedef typename proto::base_expr<
  72. Domain
  73. , tag::function
  74. , list3<
  75. Expr &
  76. , typename proto::result_of::as_child<A0, Domain>::type , typename proto::result_of::as_child<A1, Domain>::type
  77. >
  78. >::type type;
  79. BOOST_FORCEINLINE
  80. static type const call(
  81. Expr &e
  82. , A0 &a0 , A1 &a1
  83. )
  84. {
  85. type that = {
  86. e
  87. , proto::as_child<Domain>(a0) , proto::as_child<Domain>(a1)
  88. };
  89. return that;
  90. }
  91. };
  92. template<typename Expr , typename A0 , typename A1, typename This, typename Domain>
  93. struct funop<Expr(A0 , A1), This, Domain>
  94. : funop2<
  95. typename detail::same_cv<Expr, This>::type
  96. , Domain
  97. , typename remove_reference<A0 >::type , typename remove_reference<A1 >::type
  98. >
  99. {};
  100. template<typename Expr, typename Domain , typename A0 , typename A1 , typename A2>
  101. struct funop3
  102. {
  103. typedef typename proto::base_expr<
  104. Domain
  105. , tag::function
  106. , list4<
  107. Expr &
  108. , typename proto::result_of::as_child<A0, Domain>::type , typename proto::result_of::as_child<A1, Domain>::type , typename proto::result_of::as_child<A2, Domain>::type
  109. >
  110. >::type type;
  111. BOOST_FORCEINLINE
  112. static type const call(
  113. Expr &e
  114. , A0 &a0 , A1 &a1 , A2 &a2
  115. )
  116. {
  117. type that = {
  118. e
  119. , proto::as_child<Domain>(a0) , proto::as_child<Domain>(a1) , proto::as_child<Domain>(a2)
  120. };
  121. return that;
  122. }
  123. };
  124. template<typename Expr , typename A0 , typename A1 , typename A2, typename This, typename Domain>
  125. struct funop<Expr(A0 , A1 , A2), This, Domain>
  126. : funop3<
  127. typename detail::same_cv<Expr, This>::type
  128. , Domain
  129. , typename remove_reference<A0 >::type , typename remove_reference<A1 >::type , typename remove_reference<A2 >::type
  130. >
  131. {};
  132. template<typename Expr, typename Domain , typename A0 , typename A1 , typename A2 , typename A3>
  133. struct funop4
  134. {
  135. typedef typename proto::base_expr<
  136. Domain
  137. , tag::function
  138. , list5<
  139. Expr &
  140. , typename proto::result_of::as_child<A0, Domain>::type , typename proto::result_of::as_child<A1, Domain>::type , typename proto::result_of::as_child<A2, Domain>::type , typename proto::result_of::as_child<A3, Domain>::type
  141. >
  142. >::type type;
  143. BOOST_FORCEINLINE
  144. static type const call(
  145. Expr &e
  146. , A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3
  147. )
  148. {
  149. type that = {
  150. e
  151. , proto::as_child<Domain>(a0) , proto::as_child<Domain>(a1) , proto::as_child<Domain>(a2) , proto::as_child<Domain>(a3)
  152. };
  153. return that;
  154. }
  155. };
  156. template<typename Expr , typename A0 , typename A1 , typename A2 , typename A3, typename This, typename Domain>
  157. struct funop<Expr(A0 , A1 , A2 , A3), This, Domain>
  158. : funop4<
  159. typename detail::same_cv<Expr, This>::type
  160. , Domain
  161. , typename remove_reference<A0 >::type , typename remove_reference<A1 >::type , typename remove_reference<A2 >::type , typename remove_reference<A3 >::type
  162. >
  163. {};
  164. template<typename Expr, typename Domain , typename A0 , typename A1 , typename A2 , typename A3 , typename A4>
  165. struct funop5
  166. {
  167. typedef typename proto::base_expr<
  168. Domain
  169. , tag::function
  170. , list6<
  171. Expr &
  172. , typename proto::result_of::as_child<A0, Domain>::type , typename proto::result_of::as_child<A1, Domain>::type , typename proto::result_of::as_child<A2, Domain>::type , typename proto::result_of::as_child<A3, Domain>::type , typename proto::result_of::as_child<A4, Domain>::type
  173. >
  174. >::type type;
  175. BOOST_FORCEINLINE
  176. static type const call(
  177. Expr &e
  178. , A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4
  179. )
  180. {
  181. type that = {
  182. e
  183. , proto::as_child<Domain>(a0) , proto::as_child<Domain>(a1) , proto::as_child<Domain>(a2) , proto::as_child<Domain>(a3) , proto::as_child<Domain>(a4)
  184. };
  185. return that;
  186. }
  187. };
  188. template<typename Expr , typename A0 , typename A1 , typename A2 , typename A3 , typename A4, typename This, typename Domain>
  189. struct funop<Expr(A0 , A1 , A2 , A3 , A4), This, Domain>
  190. : funop5<
  191. typename detail::same_cv<Expr, This>::type
  192. , Domain
  193. , typename remove_reference<A0 >::type , typename remove_reference<A1 >::type , typename remove_reference<A2 >::type , typename remove_reference<A3 >::type , typename remove_reference<A4 >::type
  194. >
  195. {};
  196. template<typename Expr, typename Domain , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5>
  197. struct funop6
  198. {
  199. typedef typename proto::base_expr<
  200. Domain
  201. , tag::function
  202. , list7<
  203. Expr &
  204. , typename proto::result_of::as_child<A0, Domain>::type , typename proto::result_of::as_child<A1, Domain>::type , typename proto::result_of::as_child<A2, Domain>::type , typename proto::result_of::as_child<A3, Domain>::type , typename proto::result_of::as_child<A4, Domain>::type , typename proto::result_of::as_child<A5, Domain>::type
  205. >
  206. >::type type;
  207. BOOST_FORCEINLINE
  208. static type const call(
  209. Expr &e
  210. , A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5
  211. )
  212. {
  213. type that = {
  214. e
  215. , proto::as_child<Domain>(a0) , proto::as_child<Domain>(a1) , proto::as_child<Domain>(a2) , proto::as_child<Domain>(a3) , proto::as_child<Domain>(a4) , proto::as_child<Domain>(a5)
  216. };
  217. return that;
  218. }
  219. };
  220. template<typename Expr , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5, typename This, typename Domain>
  221. struct funop<Expr(A0 , A1 , A2 , A3 , A4 , A5), This, Domain>
  222. : funop6<
  223. typename detail::same_cv<Expr, This>::type
  224. , Domain
  225. , typename remove_reference<A0 >::type , typename remove_reference<A1 >::type , typename remove_reference<A2 >::type , typename remove_reference<A3 >::type , typename remove_reference<A4 >::type , typename remove_reference<A5 >::type
  226. >
  227. {};
  228. template<typename Expr, typename Domain , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6>
  229. struct funop7
  230. {
  231. typedef typename proto::base_expr<
  232. Domain
  233. , tag::function
  234. , list8<
  235. Expr &
  236. , typename proto::result_of::as_child<A0, Domain>::type , typename proto::result_of::as_child<A1, Domain>::type , typename proto::result_of::as_child<A2, Domain>::type , typename proto::result_of::as_child<A3, Domain>::type , typename proto::result_of::as_child<A4, Domain>::type , typename proto::result_of::as_child<A5, Domain>::type , typename proto::result_of::as_child<A6, Domain>::type
  237. >
  238. >::type type;
  239. BOOST_FORCEINLINE
  240. static type const call(
  241. Expr &e
  242. , A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5 , A6 &a6
  243. )
  244. {
  245. type that = {
  246. e
  247. , proto::as_child<Domain>(a0) , proto::as_child<Domain>(a1) , proto::as_child<Domain>(a2) , proto::as_child<Domain>(a3) , proto::as_child<Domain>(a4) , proto::as_child<Domain>(a5) , proto::as_child<Domain>(a6)
  248. };
  249. return that;
  250. }
  251. };
  252. template<typename Expr , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6, typename This, typename Domain>
  253. struct funop<Expr(A0 , A1 , A2 , A3 , A4 , A5 , A6), This, Domain>
  254. : funop7<
  255. typename detail::same_cv<Expr, This>::type
  256. , Domain
  257. , typename remove_reference<A0 >::type , typename remove_reference<A1 >::type , typename remove_reference<A2 >::type , typename remove_reference<A3 >::type , typename remove_reference<A4 >::type , typename remove_reference<A5 >::type , typename remove_reference<A6 >::type
  258. >
  259. {};
  260. template<typename Expr, typename Domain , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7>
  261. struct funop8
  262. {
  263. typedef typename proto::base_expr<
  264. Domain
  265. , tag::function
  266. , list9<
  267. Expr &
  268. , typename proto::result_of::as_child<A0, Domain>::type , typename proto::result_of::as_child<A1, Domain>::type , typename proto::result_of::as_child<A2, Domain>::type , typename proto::result_of::as_child<A3, Domain>::type , typename proto::result_of::as_child<A4, Domain>::type , typename proto::result_of::as_child<A5, Domain>::type , typename proto::result_of::as_child<A6, Domain>::type , typename proto::result_of::as_child<A7, Domain>::type
  269. >
  270. >::type type;
  271. BOOST_FORCEINLINE
  272. static type const call(
  273. Expr &e
  274. , A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5 , A6 &a6 , A7 &a7
  275. )
  276. {
  277. type that = {
  278. e
  279. , proto::as_child<Domain>(a0) , proto::as_child<Domain>(a1) , proto::as_child<Domain>(a2) , proto::as_child<Domain>(a3) , proto::as_child<Domain>(a4) , proto::as_child<Domain>(a5) , proto::as_child<Domain>(a6) , proto::as_child<Domain>(a7)
  280. };
  281. return that;
  282. }
  283. };
  284. template<typename Expr , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7, typename This, typename Domain>
  285. struct funop<Expr(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7), This, Domain>
  286. : funop8<
  287. typename detail::same_cv<Expr, This>::type
  288. , Domain
  289. , typename remove_reference<A0 >::type , typename remove_reference<A1 >::type , typename remove_reference<A2 >::type , typename remove_reference<A3 >::type , typename remove_reference<A4 >::type , typename remove_reference<A5 >::type , typename remove_reference<A6 >::type , typename remove_reference<A7 >::type
  290. >
  291. {};
  292. template<typename Expr, typename Domain , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8>
  293. struct funop9
  294. {
  295. typedef typename proto::base_expr<
  296. Domain
  297. , tag::function
  298. , list10<
  299. Expr &
  300. , typename proto::result_of::as_child<A0, Domain>::type , typename proto::result_of::as_child<A1, Domain>::type , typename proto::result_of::as_child<A2, Domain>::type , typename proto::result_of::as_child<A3, Domain>::type , typename proto::result_of::as_child<A4, Domain>::type , typename proto::result_of::as_child<A5, Domain>::type , typename proto::result_of::as_child<A6, Domain>::type , typename proto::result_of::as_child<A7, Domain>::type , typename proto::result_of::as_child<A8, Domain>::type
  301. >
  302. >::type type;
  303. BOOST_FORCEINLINE
  304. static type const call(
  305. Expr &e
  306. , A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5 , A6 &a6 , A7 &a7 , A8 &a8
  307. )
  308. {
  309. type that = {
  310. e
  311. , proto::as_child<Domain>(a0) , proto::as_child<Domain>(a1) , proto::as_child<Domain>(a2) , proto::as_child<Domain>(a3) , proto::as_child<Domain>(a4) , proto::as_child<Domain>(a5) , proto::as_child<Domain>(a6) , proto::as_child<Domain>(a7) , proto::as_child<Domain>(a8)
  312. };
  313. return that;
  314. }
  315. };
  316. template<typename Expr , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8, typename This, typename Domain>
  317. struct funop<Expr(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8), This, Domain>
  318. : funop9<
  319. typename detail::same_cv<Expr, This>::type
  320. , Domain
  321. , typename remove_reference<A0 >::type , typename remove_reference<A1 >::type , typename remove_reference<A2 >::type , typename remove_reference<A3 >::type , typename remove_reference<A4 >::type , typename remove_reference<A5 >::type , typename remove_reference<A6 >::type , typename remove_reference<A7 >::type , typename remove_reference<A8 >::type
  322. >
  323. {};