basic_bind.hpp 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. // Copyright Peter Dimov 2001
  2. // Copyright Aleksey Gurtovoy 2001-2004
  3. //
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // Preprocessed version of "boost/mpl/aux_/basic_bind.hpp" header
  9. // -- DO NOT modify by hand!
  10. namespace boost { namespace mpl {
  11. namespace aux {
  12. template< bool >
  13. struct resolve_arg_impl
  14. {
  15. template<
  16. typename T, typename U1, typename U2, typename U3
  17. , typename U4, typename U5
  18. >
  19. struct result_
  20. {
  21. typedef T type;
  22. };
  23. };
  24. template<>
  25. struct resolve_arg_impl<true>
  26. {
  27. template<
  28. typename T, typename U1, typename U2, typename U3
  29. , typename U4, typename U5
  30. >
  31. struct result_
  32. {
  33. typedef typename apply_wrap5<
  34. T
  35. , U1, U2, U3, U4, U5
  36. >::type type;
  37. };
  38. };
  39. template< typename T > struct is_bind_template;
  40. template<
  41. typename T, typename U1, typename U2, typename U3, typename U4
  42. , typename U5
  43. >
  44. struct resolve_bind_arg
  45. : resolve_arg_impl< is_bind_template<T>::value >
  46. ::template result_< T,U1,U2,U3,U4,U5 >
  47. {
  48. };
  49. template< int arity_ > struct bind_chooser;
  50. aux::no_tag is_bind_helper(...);
  51. template< typename T > aux::no_tag is_bind_helper(protect<T>*);
  52. template<
  53. typename F, typename T1, typename T2, typename T3, typename T4
  54. , typename T5
  55. >
  56. aux::yes_tag is_bind_helper(bind< F,T1,T2,T3,T4,T5 >*);
  57. template< int N >
  58. aux::yes_tag is_bind_helper(arg<N>*);
  59. template< bool is_ref_ = true >
  60. struct is_bind_template_impl
  61. {
  62. template< typename T > struct result_
  63. {
  64. BOOST_STATIC_CONSTANT(bool, value = false);
  65. };
  66. };
  67. template<>
  68. struct is_bind_template_impl<false>
  69. {
  70. template< typename T > struct result_
  71. {
  72. BOOST_STATIC_CONSTANT(bool, value =
  73. sizeof(aux::is_bind_helper(static_cast<T*>(0)))
  74. == sizeof(aux::yes_tag)
  75. );
  76. };
  77. };
  78. template< typename T > struct is_bind_template
  79. : is_bind_template_impl< ::boost::detail::is_reference_impl<T>::value >
  80. ::template result_<T>
  81. {
  82. };
  83. } // namespace aux
  84. template<
  85. typename F
  86. >
  87. struct bind0
  88. {
  89. template<
  90. typename U1 = na, typename U2 = na, typename U3 = na
  91. , typename U4 = na, typename U5 = na
  92. >
  93. struct apply
  94. {
  95. private:
  96. typedef typename aux::resolve_bind_arg< F,U1,U2,U3,U4,U5 >::type f_;
  97. public:
  98. typedef typename apply_wrap0<
  99. f_
  100. >::type type;
  101. };
  102. };
  103. namespace aux {
  104. template<
  105. typename F
  106. >
  107. aux::yes_tag
  108. is_bind_helper(bind0<F>*);
  109. } // namespace aux
  110. BOOST_MPL_AUX_ARITY_SPEC(1, bind0)
  111. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(1, bind0)
  112. namespace aux {
  113. template<>
  114. struct bind_chooser<0>
  115. {
  116. template<
  117. typename F, typename T1, typename T2, typename T3, typename T4
  118. , typename T5
  119. >
  120. struct result_
  121. {
  122. typedef bind0<F> type;
  123. };
  124. };
  125. } // namespace aux
  126. template<
  127. typename F, typename T1
  128. >
  129. struct bind1
  130. {
  131. template<
  132. typename U1 = na, typename U2 = na, typename U3 = na
  133. , typename U4 = na, typename U5 = na
  134. >
  135. struct apply
  136. {
  137. private:
  138. typedef typename aux::resolve_bind_arg< F,U1,U2,U3,U4,U5 >::type f_;
  139. typedef aux::resolve_bind_arg< T1,U1,U2,U3,U4,U5 > t1;
  140. public:
  141. typedef typename apply_wrap1<
  142. f_
  143. , typename t1::type
  144. >::type type;
  145. };
  146. };
  147. namespace aux {
  148. template<
  149. typename F, typename T1
  150. >
  151. aux::yes_tag
  152. is_bind_helper(bind1< F,T1 >*);
  153. } // namespace aux
  154. BOOST_MPL_AUX_ARITY_SPEC(2, bind1)
  155. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(2, bind1)
  156. namespace aux {
  157. template<>
  158. struct bind_chooser<1>
  159. {
  160. template<
  161. typename F, typename T1, typename T2, typename T3, typename T4
  162. , typename T5
  163. >
  164. struct result_
  165. {
  166. typedef bind1< F,T1 > type;
  167. };
  168. };
  169. } // namespace aux
  170. template<
  171. typename F, typename T1, typename T2
  172. >
  173. struct bind2
  174. {
  175. template<
  176. typename U1 = na, typename U2 = na, typename U3 = na
  177. , typename U4 = na, typename U5 = na
  178. >
  179. struct apply
  180. {
  181. private:
  182. typedef typename aux::resolve_bind_arg< F,U1,U2,U3,U4,U5 >::type f_;
  183. typedef aux::resolve_bind_arg< T1,U1,U2,U3,U4,U5 > t1;
  184. typedef aux::resolve_bind_arg< T2,U1,U2,U3,U4,U5 > t2;
  185. public:
  186. typedef typename apply_wrap2<
  187. f_
  188. , typename t1::type, typename t2::type
  189. >::type type;
  190. };
  191. };
  192. namespace aux {
  193. template<
  194. typename F, typename T1, typename T2
  195. >
  196. aux::yes_tag
  197. is_bind_helper(bind2< F,T1,T2 >*);
  198. } // namespace aux
  199. BOOST_MPL_AUX_ARITY_SPEC(3, bind2)
  200. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(3, bind2)
  201. namespace aux {
  202. template<>
  203. struct bind_chooser<2>
  204. {
  205. template<
  206. typename F, typename T1, typename T2, typename T3, typename T4
  207. , typename T5
  208. >
  209. struct result_
  210. {
  211. typedef bind2< F,T1,T2 > type;
  212. };
  213. };
  214. } // namespace aux
  215. template<
  216. typename F, typename T1, typename T2, typename T3
  217. >
  218. struct bind3
  219. {
  220. template<
  221. typename U1 = na, typename U2 = na, typename U3 = na
  222. , typename U4 = na, typename U5 = na
  223. >
  224. struct apply
  225. {
  226. private:
  227. typedef typename aux::resolve_bind_arg< F,U1,U2,U3,U4,U5 >::type f_;
  228. typedef aux::resolve_bind_arg< T1,U1,U2,U3,U4,U5 > t1;
  229. typedef aux::resolve_bind_arg< T2,U1,U2,U3,U4,U5 > t2;
  230. typedef aux::resolve_bind_arg< T3,U1,U2,U3,U4,U5 > t3;
  231. public:
  232. typedef typename apply_wrap3<
  233. f_
  234. , typename t1::type, typename t2::type, typename t3::type
  235. >::type type;
  236. };
  237. };
  238. namespace aux {
  239. template<
  240. typename F, typename T1, typename T2, typename T3
  241. >
  242. aux::yes_tag
  243. is_bind_helper(bind3< F,T1,T2,T3 >*);
  244. } // namespace aux
  245. BOOST_MPL_AUX_ARITY_SPEC(4, bind3)
  246. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(4, bind3)
  247. namespace aux {
  248. template<>
  249. struct bind_chooser<3>
  250. {
  251. template<
  252. typename F, typename T1, typename T2, typename T3, typename T4
  253. , typename T5
  254. >
  255. struct result_
  256. {
  257. typedef bind3< F,T1,T2,T3 > type;
  258. };
  259. };
  260. } // namespace aux
  261. template<
  262. typename F, typename T1, typename T2, typename T3, typename T4
  263. >
  264. struct bind4
  265. {
  266. template<
  267. typename U1 = na, typename U2 = na, typename U3 = na
  268. , typename U4 = na, typename U5 = na
  269. >
  270. struct apply
  271. {
  272. private:
  273. typedef typename aux::resolve_bind_arg< F,U1,U2,U3,U4,U5 >::type f_;
  274. typedef aux::resolve_bind_arg< T1,U1,U2,U3,U4,U5 > t1;
  275. typedef aux::resolve_bind_arg< T2,U1,U2,U3,U4,U5 > t2;
  276. typedef aux::resolve_bind_arg< T3,U1,U2,U3,U4,U5 > t3;
  277. typedef aux::resolve_bind_arg< T4,U1,U2,U3,U4,U5 > t4;
  278. public:
  279. typedef typename apply_wrap4<
  280. f_
  281. , typename t1::type, typename t2::type, typename t3::type
  282. , typename t4::type
  283. >::type type;
  284. };
  285. };
  286. namespace aux {
  287. template<
  288. typename F, typename T1, typename T2, typename T3, typename T4
  289. >
  290. aux::yes_tag
  291. is_bind_helper(bind4< F,T1,T2,T3,T4 >*);
  292. } // namespace aux
  293. BOOST_MPL_AUX_ARITY_SPEC(5, bind4)
  294. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(5, bind4)
  295. namespace aux {
  296. template<>
  297. struct bind_chooser<4>
  298. {
  299. template<
  300. typename F, typename T1, typename T2, typename T3, typename T4
  301. , typename T5
  302. >
  303. struct result_
  304. {
  305. typedef bind4< F,T1,T2,T3,T4 > type;
  306. };
  307. };
  308. } // namespace aux
  309. template<
  310. typename F, typename T1, typename T2, typename T3, typename T4
  311. , typename T5
  312. >
  313. struct bind5
  314. {
  315. template<
  316. typename U1 = na, typename U2 = na, typename U3 = na
  317. , typename U4 = na, typename U5 = na
  318. >
  319. struct apply
  320. {
  321. private:
  322. typedef typename aux::resolve_bind_arg< F,U1,U2,U3,U4,U5 >::type f_;
  323. typedef aux::resolve_bind_arg< T1,U1,U2,U3,U4,U5 > t1;
  324. typedef aux::resolve_bind_arg< T2,U1,U2,U3,U4,U5 > t2;
  325. typedef aux::resolve_bind_arg< T3,U1,U2,U3,U4,U5 > t3;
  326. typedef aux::resolve_bind_arg< T4,U1,U2,U3,U4,U5 > t4;
  327. typedef aux::resolve_bind_arg< T5,U1,U2,U3,U4,U5 > t5;
  328. public:
  329. typedef typename apply_wrap5<
  330. f_
  331. , typename t1::type, typename t2::type, typename t3::type
  332. , typename t4::type, typename t5::type
  333. >::type type;
  334. };
  335. };
  336. namespace aux {
  337. template<
  338. typename F, typename T1, typename T2, typename T3, typename T4
  339. , typename T5
  340. >
  341. aux::yes_tag
  342. is_bind_helper(bind5< F,T1,T2,T3,T4,T5 >*);
  343. } // namespace aux
  344. BOOST_MPL_AUX_ARITY_SPEC(6, bind5)
  345. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(6, bind5)
  346. namespace aux {
  347. template<>
  348. struct bind_chooser<5>
  349. {
  350. template<
  351. typename F, typename T1, typename T2, typename T3, typename T4
  352. , typename T5
  353. >
  354. struct result_
  355. {
  356. typedef bind5< F,T1,T2,T3,T4,T5 > type;
  357. };
  358. };
  359. } // namespace aux
  360. namespace aux {
  361. template< typename T >
  362. struct is_bind_arg
  363. {
  364. BOOST_STATIC_CONSTANT(bool, value = true);
  365. };
  366. template<>
  367. struct is_bind_arg<na>
  368. {
  369. BOOST_STATIC_CONSTANT(bool, value = false);
  370. };
  371. template<
  372. typename T1, typename T2, typename T3, typename T4, typename T5
  373. >
  374. struct bind_count_args
  375. {
  376. BOOST_STATIC_CONSTANT(int, value =
  377. is_bind_arg<T1>::value + is_bind_arg<T2>::value
  378. + is_bind_arg<T3>::value + is_bind_arg<T4>::value
  379. + is_bind_arg<T5>::value
  380. );
  381. };
  382. }
  383. template<
  384. typename F, typename T1, typename T2, typename T3, typename T4
  385. , typename T5
  386. >
  387. struct bind
  388. : aux::bind_chooser<
  389. aux::bind_count_args< T1,T2,T3,T4,T5 >::value
  390. >::template result_< F,T1,T2,T3,T4,T5 >::type
  391. {
  392. };
  393. BOOST_MPL_AUX_ARITY_SPEC(
  394. 6
  395. , bind
  396. )
  397. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(
  398. 6
  399. , bind
  400. )
  401. }}