callable_eval.hpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. ///////////////////////////////////////////////////////////////////////////////
  2. /// \file callable_eval.hpp
  3. /// Contains specializations of the callable_eval\<\> 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. namespace detail
  9. {
  10. template<typename Expr, typename Context>
  11. struct is_expr_handled<Expr, Context, 1>
  12. {
  13. static callable_context_wrapper<Context> &sctx_;
  14. static Expr &sexpr_;
  15. static typename Expr::proto_tag &stag_;
  16. static const bool value =
  17. sizeof(yes_type) ==
  18. sizeof(
  19. detail::check_is_expr_handled(
  20. (sctx_(
  21. stag_
  22. , proto::child_c< 0>( sexpr_)
  23. ), 0)
  24. )
  25. );
  26. typedef mpl::bool_<value> type;
  27. };
  28. }
  29. namespace context
  30. {
  31. template<typename Expr, typename Context>
  32. struct callable_eval<Expr, Context, 1>
  33. {
  34. typedef typename proto::result_of::child_c< Expr const &, 0>::type child0;
  35. typedef
  36. typename BOOST_PROTO_RESULT_OF<
  37. Context(
  38. typename Expr::proto_tag
  39. , child0
  40. )
  41. >::type
  42. result_type;
  43. result_type operator ()(Expr &expr, Context &context) const
  44. {
  45. return context(
  46. typename Expr::proto_tag()
  47. , proto::child_c< 0>( expr)
  48. );
  49. }
  50. };
  51. }
  52. namespace detail
  53. {
  54. template<typename Expr, typename Context>
  55. struct is_expr_handled<Expr, Context, 2>
  56. {
  57. static callable_context_wrapper<Context> &sctx_;
  58. static Expr &sexpr_;
  59. static typename Expr::proto_tag &stag_;
  60. static const bool value =
  61. sizeof(yes_type) ==
  62. sizeof(
  63. detail::check_is_expr_handled(
  64. (sctx_(
  65. stag_
  66. , proto::child_c< 0>( sexpr_) , proto::child_c< 1>( sexpr_)
  67. ), 0)
  68. )
  69. );
  70. typedef mpl::bool_<value> type;
  71. };
  72. }
  73. namespace context
  74. {
  75. template<typename Expr, typename Context>
  76. struct callable_eval<Expr, Context, 2>
  77. {
  78. typedef typename proto::result_of::child_c< Expr const &, 0>::type child0; typedef typename proto::result_of::child_c< Expr const &, 1>::type child1;
  79. typedef
  80. typename BOOST_PROTO_RESULT_OF<
  81. Context(
  82. typename Expr::proto_tag
  83. , child0 , child1
  84. )
  85. >::type
  86. result_type;
  87. result_type operator ()(Expr &expr, Context &context) const
  88. {
  89. return context(
  90. typename Expr::proto_tag()
  91. , proto::child_c< 0>( expr) , proto::child_c< 1>( expr)
  92. );
  93. }
  94. };
  95. }
  96. namespace detail
  97. {
  98. template<typename Expr, typename Context>
  99. struct is_expr_handled<Expr, Context, 3>
  100. {
  101. static callable_context_wrapper<Context> &sctx_;
  102. static Expr &sexpr_;
  103. static typename Expr::proto_tag &stag_;
  104. static const bool value =
  105. sizeof(yes_type) ==
  106. sizeof(
  107. detail::check_is_expr_handled(
  108. (sctx_(
  109. stag_
  110. , proto::child_c< 0>( sexpr_) , proto::child_c< 1>( sexpr_) , proto::child_c< 2>( sexpr_)
  111. ), 0)
  112. )
  113. );
  114. typedef mpl::bool_<value> type;
  115. };
  116. }
  117. namespace context
  118. {
  119. template<typename Expr, typename Context>
  120. struct callable_eval<Expr, Context, 3>
  121. {
  122. typedef typename proto::result_of::child_c< Expr const &, 0>::type child0; typedef typename proto::result_of::child_c< Expr const &, 1>::type child1; typedef typename proto::result_of::child_c< Expr const &, 2>::type child2;
  123. typedef
  124. typename BOOST_PROTO_RESULT_OF<
  125. Context(
  126. typename Expr::proto_tag
  127. , child0 , child1 , child2
  128. )
  129. >::type
  130. result_type;
  131. result_type operator ()(Expr &expr, Context &context) const
  132. {
  133. return context(
  134. typename Expr::proto_tag()
  135. , proto::child_c< 0>( expr) , proto::child_c< 1>( expr) , proto::child_c< 2>( expr)
  136. );
  137. }
  138. };
  139. }
  140. namespace detail
  141. {
  142. template<typename Expr, typename Context>
  143. struct is_expr_handled<Expr, Context, 4>
  144. {
  145. static callable_context_wrapper<Context> &sctx_;
  146. static Expr &sexpr_;
  147. static typename Expr::proto_tag &stag_;
  148. static const bool value =
  149. sizeof(yes_type) ==
  150. sizeof(
  151. detail::check_is_expr_handled(
  152. (sctx_(
  153. stag_
  154. , proto::child_c< 0>( sexpr_) , proto::child_c< 1>( sexpr_) , proto::child_c< 2>( sexpr_) , proto::child_c< 3>( sexpr_)
  155. ), 0)
  156. )
  157. );
  158. typedef mpl::bool_<value> type;
  159. };
  160. }
  161. namespace context
  162. {
  163. template<typename Expr, typename Context>
  164. struct callable_eval<Expr, Context, 4>
  165. {
  166. typedef typename proto::result_of::child_c< Expr const &, 0>::type child0; typedef typename proto::result_of::child_c< Expr const &, 1>::type child1; typedef typename proto::result_of::child_c< Expr const &, 2>::type child2; typedef typename proto::result_of::child_c< Expr const &, 3>::type child3;
  167. typedef
  168. typename BOOST_PROTO_RESULT_OF<
  169. Context(
  170. typename Expr::proto_tag
  171. , child0 , child1 , child2 , child3
  172. )
  173. >::type
  174. result_type;
  175. result_type operator ()(Expr &expr, Context &context) const
  176. {
  177. return context(
  178. typename Expr::proto_tag()
  179. , proto::child_c< 0>( expr) , proto::child_c< 1>( expr) , proto::child_c< 2>( expr) , proto::child_c< 3>( expr)
  180. );
  181. }
  182. };
  183. }
  184. namespace detail
  185. {
  186. template<typename Expr, typename Context>
  187. struct is_expr_handled<Expr, Context, 5>
  188. {
  189. static callable_context_wrapper<Context> &sctx_;
  190. static Expr &sexpr_;
  191. static typename Expr::proto_tag &stag_;
  192. static const bool value =
  193. sizeof(yes_type) ==
  194. sizeof(
  195. detail::check_is_expr_handled(
  196. (sctx_(
  197. stag_
  198. , proto::child_c< 0>( sexpr_) , proto::child_c< 1>( sexpr_) , proto::child_c< 2>( sexpr_) , proto::child_c< 3>( sexpr_) , proto::child_c< 4>( sexpr_)
  199. ), 0)
  200. )
  201. );
  202. typedef mpl::bool_<value> type;
  203. };
  204. }
  205. namespace context
  206. {
  207. template<typename Expr, typename Context>
  208. struct callable_eval<Expr, Context, 5>
  209. {
  210. typedef typename proto::result_of::child_c< Expr const &, 0>::type child0; typedef typename proto::result_of::child_c< Expr const &, 1>::type child1; typedef typename proto::result_of::child_c< Expr const &, 2>::type child2; typedef typename proto::result_of::child_c< Expr const &, 3>::type child3; typedef typename proto::result_of::child_c< Expr const &, 4>::type child4;
  211. typedef
  212. typename BOOST_PROTO_RESULT_OF<
  213. Context(
  214. typename Expr::proto_tag
  215. , child0 , child1 , child2 , child3 , child4
  216. )
  217. >::type
  218. result_type;
  219. result_type operator ()(Expr &expr, Context &context) const
  220. {
  221. return context(
  222. typename Expr::proto_tag()
  223. , proto::child_c< 0>( expr) , proto::child_c< 1>( expr) , proto::child_c< 2>( expr) , proto::child_c< 3>( expr) , proto::child_c< 4>( expr)
  224. );
  225. }
  226. };
  227. }
  228. namespace detail
  229. {
  230. template<typename Expr, typename Context>
  231. struct is_expr_handled<Expr, Context, 6>
  232. {
  233. static callable_context_wrapper<Context> &sctx_;
  234. static Expr &sexpr_;
  235. static typename Expr::proto_tag &stag_;
  236. static const bool value =
  237. sizeof(yes_type) ==
  238. sizeof(
  239. detail::check_is_expr_handled(
  240. (sctx_(
  241. stag_
  242. , proto::child_c< 0>( sexpr_) , proto::child_c< 1>( sexpr_) , proto::child_c< 2>( sexpr_) , proto::child_c< 3>( sexpr_) , proto::child_c< 4>( sexpr_) , proto::child_c< 5>( sexpr_)
  243. ), 0)
  244. )
  245. );
  246. typedef mpl::bool_<value> type;
  247. };
  248. }
  249. namespace context
  250. {
  251. template<typename Expr, typename Context>
  252. struct callable_eval<Expr, Context, 6>
  253. {
  254. typedef typename proto::result_of::child_c< Expr const &, 0>::type child0; typedef typename proto::result_of::child_c< Expr const &, 1>::type child1; typedef typename proto::result_of::child_c< Expr const &, 2>::type child2; typedef typename proto::result_of::child_c< Expr const &, 3>::type child3; typedef typename proto::result_of::child_c< Expr const &, 4>::type child4; typedef typename proto::result_of::child_c< Expr const &, 5>::type child5;
  255. typedef
  256. typename BOOST_PROTO_RESULT_OF<
  257. Context(
  258. typename Expr::proto_tag
  259. , child0 , child1 , child2 , child3 , child4 , child5
  260. )
  261. >::type
  262. result_type;
  263. result_type operator ()(Expr &expr, Context &context) const
  264. {
  265. return context(
  266. typename Expr::proto_tag()
  267. , proto::child_c< 0>( expr) , proto::child_c< 1>( expr) , proto::child_c< 2>( expr) , proto::child_c< 3>( expr) , proto::child_c< 4>( expr) , proto::child_c< 5>( expr)
  268. );
  269. }
  270. };
  271. }
  272. namespace detail
  273. {
  274. template<typename Expr, typename Context>
  275. struct is_expr_handled<Expr, Context, 7>
  276. {
  277. static callable_context_wrapper<Context> &sctx_;
  278. static Expr &sexpr_;
  279. static typename Expr::proto_tag &stag_;
  280. static const bool value =
  281. sizeof(yes_type) ==
  282. sizeof(
  283. detail::check_is_expr_handled(
  284. (sctx_(
  285. stag_
  286. , proto::child_c< 0>( sexpr_) , proto::child_c< 1>( sexpr_) , proto::child_c< 2>( sexpr_) , proto::child_c< 3>( sexpr_) , proto::child_c< 4>( sexpr_) , proto::child_c< 5>( sexpr_) , proto::child_c< 6>( sexpr_)
  287. ), 0)
  288. )
  289. );
  290. typedef mpl::bool_<value> type;
  291. };
  292. }
  293. namespace context
  294. {
  295. template<typename Expr, typename Context>
  296. struct callable_eval<Expr, Context, 7>
  297. {
  298. typedef typename proto::result_of::child_c< Expr const &, 0>::type child0; typedef typename proto::result_of::child_c< Expr const &, 1>::type child1; typedef typename proto::result_of::child_c< Expr const &, 2>::type child2; typedef typename proto::result_of::child_c< Expr const &, 3>::type child3; typedef typename proto::result_of::child_c< Expr const &, 4>::type child4; typedef typename proto::result_of::child_c< Expr const &, 5>::type child5; typedef typename proto::result_of::child_c< Expr const &, 6>::type child6;
  299. typedef
  300. typename BOOST_PROTO_RESULT_OF<
  301. Context(
  302. typename Expr::proto_tag
  303. , child0 , child1 , child2 , child3 , child4 , child5 , child6
  304. )
  305. >::type
  306. result_type;
  307. result_type operator ()(Expr &expr, Context &context) const
  308. {
  309. return context(
  310. typename Expr::proto_tag()
  311. , proto::child_c< 0>( expr) , proto::child_c< 1>( expr) , proto::child_c< 2>( expr) , proto::child_c< 3>( expr) , proto::child_c< 4>( expr) , proto::child_c< 5>( expr) , proto::child_c< 6>( expr)
  312. );
  313. }
  314. };
  315. }
  316. namespace detail
  317. {
  318. template<typename Expr, typename Context>
  319. struct is_expr_handled<Expr, Context, 8>
  320. {
  321. static callable_context_wrapper<Context> &sctx_;
  322. static Expr &sexpr_;
  323. static typename Expr::proto_tag &stag_;
  324. static const bool value =
  325. sizeof(yes_type) ==
  326. sizeof(
  327. detail::check_is_expr_handled(
  328. (sctx_(
  329. stag_
  330. , proto::child_c< 0>( sexpr_) , proto::child_c< 1>( sexpr_) , proto::child_c< 2>( sexpr_) , proto::child_c< 3>( sexpr_) , proto::child_c< 4>( sexpr_) , proto::child_c< 5>( sexpr_) , proto::child_c< 6>( sexpr_) , proto::child_c< 7>( sexpr_)
  331. ), 0)
  332. )
  333. );
  334. typedef mpl::bool_<value> type;
  335. };
  336. }
  337. namespace context
  338. {
  339. template<typename Expr, typename Context>
  340. struct callable_eval<Expr, Context, 8>
  341. {
  342. typedef typename proto::result_of::child_c< Expr const &, 0>::type child0; typedef typename proto::result_of::child_c< Expr const &, 1>::type child1; typedef typename proto::result_of::child_c< Expr const &, 2>::type child2; typedef typename proto::result_of::child_c< Expr const &, 3>::type child3; typedef typename proto::result_of::child_c< Expr const &, 4>::type child4; typedef typename proto::result_of::child_c< Expr const &, 5>::type child5; typedef typename proto::result_of::child_c< Expr const &, 6>::type child6; typedef typename proto::result_of::child_c< Expr const &, 7>::type child7;
  343. typedef
  344. typename BOOST_PROTO_RESULT_OF<
  345. Context(
  346. typename Expr::proto_tag
  347. , child0 , child1 , child2 , child3 , child4 , child5 , child6 , child7
  348. )
  349. >::type
  350. result_type;
  351. result_type operator ()(Expr &expr, Context &context) const
  352. {
  353. return context(
  354. typename Expr::proto_tag()
  355. , proto::child_c< 0>( expr) , proto::child_c< 1>( expr) , proto::child_c< 2>( expr) , proto::child_c< 3>( expr) , proto::child_c< 4>( expr) , proto::child_c< 5>( expr) , proto::child_c< 6>( expr) , proto::child_c< 7>( expr)
  356. );
  357. }
  358. };
  359. }
  360. namespace detail
  361. {
  362. template<typename Expr, typename Context>
  363. struct is_expr_handled<Expr, Context, 9>
  364. {
  365. static callable_context_wrapper<Context> &sctx_;
  366. static Expr &sexpr_;
  367. static typename Expr::proto_tag &stag_;
  368. static const bool value =
  369. sizeof(yes_type) ==
  370. sizeof(
  371. detail::check_is_expr_handled(
  372. (sctx_(
  373. stag_
  374. , proto::child_c< 0>( sexpr_) , proto::child_c< 1>( sexpr_) , proto::child_c< 2>( sexpr_) , proto::child_c< 3>( sexpr_) , proto::child_c< 4>( sexpr_) , proto::child_c< 5>( sexpr_) , proto::child_c< 6>( sexpr_) , proto::child_c< 7>( sexpr_) , proto::child_c< 8>( sexpr_)
  375. ), 0)
  376. )
  377. );
  378. typedef mpl::bool_<value> type;
  379. };
  380. }
  381. namespace context
  382. {
  383. template<typename Expr, typename Context>
  384. struct callable_eval<Expr, Context, 9>
  385. {
  386. typedef typename proto::result_of::child_c< Expr const &, 0>::type child0; typedef typename proto::result_of::child_c< Expr const &, 1>::type child1; typedef typename proto::result_of::child_c< Expr const &, 2>::type child2; typedef typename proto::result_of::child_c< Expr const &, 3>::type child3; typedef typename proto::result_of::child_c< Expr const &, 4>::type child4; typedef typename proto::result_of::child_c< Expr const &, 5>::type child5; typedef typename proto::result_of::child_c< Expr const &, 6>::type child6; typedef typename proto::result_of::child_c< Expr const &, 7>::type child7; typedef typename proto::result_of::child_c< Expr const &, 8>::type child8;
  387. typedef
  388. typename BOOST_PROTO_RESULT_OF<
  389. Context(
  390. typename Expr::proto_tag
  391. , child0 , child1 , child2 , child3 , child4 , child5 , child6 , child7 , child8
  392. )
  393. >::type
  394. result_type;
  395. result_type operator ()(Expr &expr, Context &context) const
  396. {
  397. return context(
  398. typename Expr::proto_tag()
  399. , proto::child_c< 0>( expr) , proto::child_c< 1>( expr) , proto::child_c< 2>( expr) , proto::child_c< 3>( expr) , proto::child_c< 4>( expr) , proto::child_c< 5>( expr) , proto::child_c< 6>( expr) , proto::child_c< 7>( expr) , proto::child_c< 8>( expr)
  400. );
  401. }
  402. };
  403. }
  404. namespace detail
  405. {
  406. template<typename Expr, typename Context>
  407. struct is_expr_handled<Expr, Context, 10>
  408. {
  409. static callable_context_wrapper<Context> &sctx_;
  410. static Expr &sexpr_;
  411. static typename Expr::proto_tag &stag_;
  412. static const bool value =
  413. sizeof(yes_type) ==
  414. sizeof(
  415. detail::check_is_expr_handled(
  416. (sctx_(
  417. stag_
  418. , proto::child_c< 0>( sexpr_) , proto::child_c< 1>( sexpr_) , proto::child_c< 2>( sexpr_) , proto::child_c< 3>( sexpr_) , proto::child_c< 4>( sexpr_) , proto::child_c< 5>( sexpr_) , proto::child_c< 6>( sexpr_) , proto::child_c< 7>( sexpr_) , proto::child_c< 8>( sexpr_) , proto::child_c< 9>( sexpr_)
  419. ), 0)
  420. )
  421. );
  422. typedef mpl::bool_<value> type;
  423. };
  424. }
  425. namespace context
  426. {
  427. template<typename Expr, typename Context>
  428. struct callable_eval<Expr, Context, 10>
  429. {
  430. typedef typename proto::result_of::child_c< Expr const &, 0>::type child0; typedef typename proto::result_of::child_c< Expr const &, 1>::type child1; typedef typename proto::result_of::child_c< Expr const &, 2>::type child2; typedef typename proto::result_of::child_c< Expr const &, 3>::type child3; typedef typename proto::result_of::child_c< Expr const &, 4>::type child4; typedef typename proto::result_of::child_c< Expr const &, 5>::type child5; typedef typename proto::result_of::child_c< Expr const &, 6>::type child6; typedef typename proto::result_of::child_c< Expr const &, 7>::type child7; typedef typename proto::result_of::child_c< Expr const &, 8>::type child8; typedef typename proto::result_of::child_c< Expr const &, 9>::type child9;
  431. typedef
  432. typename BOOST_PROTO_RESULT_OF<
  433. Context(
  434. typename Expr::proto_tag
  435. , child0 , child1 , child2 , child3 , child4 , child5 , child6 , child7 , child8 , child9
  436. )
  437. >::type
  438. result_type;
  439. result_type operator ()(Expr &expr, Context &context) const
  440. {
  441. return context(
  442. typename Expr::proto_tag()
  443. , proto::child_c< 0>( expr) , proto::child_c< 1>( expr) , proto::child_c< 2>( expr) , proto::child_c< 3>( expr) , proto::child_c< 4>( expr) , proto::child_c< 5>( expr) , proto::child_c< 6>( expr) , proto::child_c< 7>( expr) , proto::child_c< 8>( expr) , proto::child_c< 9>( expr)
  444. );
  445. }
  446. };
  447. }