bind.hpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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/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< typename T >
  50. struct replace_unnamed_arg_impl
  51. {
  52. template< typename Arg > struct result_
  53. {
  54. typedef Arg next;
  55. typedef T type;
  56. };
  57. };
  58. template<>
  59. struct replace_unnamed_arg_impl< arg< -1 > >
  60. {
  61. template< typename Arg > struct result_
  62. {
  63. typedef typename next<Arg>::type next;
  64. typedef Arg type;
  65. };
  66. };
  67. template< typename T, typename Arg >
  68. struct replace_unnamed_arg
  69. : replace_unnamed_arg_impl<T>::template result_<Arg>
  70. {
  71. };
  72. template< int arity_ > struct bind_chooser;
  73. aux::no_tag is_bind_helper(...);
  74. template< typename T > aux::no_tag is_bind_helper(protect<T>*);
  75. template<
  76. typename F, typename T1, typename T2, typename T3, typename T4
  77. , typename T5
  78. >
  79. aux::yes_tag is_bind_helper(bind< F,T1,T2,T3,T4,T5 >*);
  80. template< int N >
  81. aux::yes_tag is_bind_helper(arg<N>*);
  82. template< bool is_ref_ = true >
  83. struct is_bind_template_impl
  84. {
  85. template< typename T > struct result_
  86. {
  87. BOOST_STATIC_CONSTANT(bool, value = false);
  88. };
  89. };
  90. template<>
  91. struct is_bind_template_impl<false>
  92. {
  93. template< typename T > struct result_
  94. {
  95. BOOST_STATIC_CONSTANT(bool, value =
  96. sizeof(aux::is_bind_helper(static_cast<T*>(0)))
  97. == sizeof(aux::yes_tag)
  98. );
  99. };
  100. };
  101. template< typename T > struct is_bind_template
  102. : is_bind_template_impl< ::boost::detail::is_reference_impl<T>::value >
  103. ::template result_<T>
  104. {
  105. };
  106. } // namespace aux
  107. template<
  108. typename F
  109. >
  110. struct bind0
  111. {
  112. template<
  113. typename U1 = na, typename U2 = na, typename U3 = na
  114. , typename U4 = na, typename U5 = na
  115. >
  116. struct apply
  117. {
  118. private:
  119. typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0;
  120. typedef typename r0::type a0;
  121. typedef typename r0::next n1;
  122. typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_;
  123. ///
  124. public:
  125. typedef typename apply_wrap0<
  126. f_
  127. >::type type;
  128. };
  129. };
  130. namespace aux {
  131. template<
  132. typename F
  133. >
  134. aux::yes_tag
  135. is_bind_helper(bind0<F>*);
  136. } // namespace aux
  137. BOOST_MPL_AUX_ARITY_SPEC(1, bind0)
  138. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(1, bind0)
  139. namespace aux {
  140. template<>
  141. struct bind_chooser<0>
  142. {
  143. template<
  144. typename F, typename T1, typename T2, typename T3, typename T4
  145. , typename T5
  146. >
  147. struct result_
  148. {
  149. typedef bind0<F> type;
  150. };
  151. };
  152. } // namespace aux
  153. template<
  154. typename F, typename T1
  155. >
  156. struct bind1
  157. {
  158. template<
  159. typename U1 = na, typename U2 = na, typename U3 = na
  160. , typename U4 = na, typename U5 = na
  161. >
  162. struct apply
  163. {
  164. private:
  165. typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0;
  166. typedef typename r0::type a0;
  167. typedef typename r0::next n1;
  168. typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_;
  169. ///
  170. typedef aux::replace_unnamed_arg< T1,n1 > r1;
  171. typedef typename r1::type a1;
  172. typedef typename r1::next n2;
  173. typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1;
  174. ///
  175. public:
  176. typedef typename apply_wrap1<
  177. f_
  178. , typename t1::type
  179. >::type type;
  180. };
  181. };
  182. namespace aux {
  183. template<
  184. typename F, typename T1
  185. >
  186. aux::yes_tag
  187. is_bind_helper(bind1< F,T1 >*);
  188. } // namespace aux
  189. BOOST_MPL_AUX_ARITY_SPEC(2, bind1)
  190. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(2, bind1)
  191. namespace aux {
  192. template<>
  193. struct bind_chooser<1>
  194. {
  195. template<
  196. typename F, typename T1, typename T2, typename T3, typename T4
  197. , typename T5
  198. >
  199. struct result_
  200. {
  201. typedef bind1< F,T1 > type;
  202. };
  203. };
  204. } // namespace aux
  205. template<
  206. typename F, typename T1, typename T2
  207. >
  208. struct bind2
  209. {
  210. template<
  211. typename U1 = na, typename U2 = na, typename U3 = na
  212. , typename U4 = na, typename U5 = na
  213. >
  214. struct apply
  215. {
  216. private:
  217. typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0;
  218. typedef typename r0::type a0;
  219. typedef typename r0::next n1;
  220. typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_;
  221. ///
  222. typedef aux::replace_unnamed_arg< T1,n1 > r1;
  223. typedef typename r1::type a1;
  224. typedef typename r1::next n2;
  225. typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1;
  226. ///
  227. typedef aux::replace_unnamed_arg< T2,n2 > r2;
  228. typedef typename r2::type a2;
  229. typedef typename r2::next n3;
  230. typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2;
  231. ///
  232. public:
  233. typedef typename apply_wrap2<
  234. f_
  235. , typename t1::type, typename t2::type
  236. >::type type;
  237. };
  238. };
  239. namespace aux {
  240. template<
  241. typename F, typename T1, typename T2
  242. >
  243. aux::yes_tag
  244. is_bind_helper(bind2< F,T1,T2 >*);
  245. } // namespace aux
  246. BOOST_MPL_AUX_ARITY_SPEC(3, bind2)
  247. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(3, bind2)
  248. namespace aux {
  249. template<>
  250. struct bind_chooser<2>
  251. {
  252. template<
  253. typename F, typename T1, typename T2, typename T3, typename T4
  254. , typename T5
  255. >
  256. struct result_
  257. {
  258. typedef bind2< F,T1,T2 > type;
  259. };
  260. };
  261. } // namespace aux
  262. template<
  263. typename F, typename T1, typename T2, typename T3
  264. >
  265. struct bind3
  266. {
  267. template<
  268. typename U1 = na, typename U2 = na, typename U3 = na
  269. , typename U4 = na, typename U5 = na
  270. >
  271. struct apply
  272. {
  273. private:
  274. typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0;
  275. typedef typename r0::type a0;
  276. typedef typename r0::next n1;
  277. typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_;
  278. ///
  279. typedef aux::replace_unnamed_arg< T1,n1 > r1;
  280. typedef typename r1::type a1;
  281. typedef typename r1::next n2;
  282. typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1;
  283. ///
  284. typedef aux::replace_unnamed_arg< T2,n2 > r2;
  285. typedef typename r2::type a2;
  286. typedef typename r2::next n3;
  287. typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2;
  288. ///
  289. typedef aux::replace_unnamed_arg< T3,n3 > r3;
  290. typedef typename r3::type a3;
  291. typedef typename r3::next n4;
  292. typedef aux::resolve_bind_arg< a3,U1,U2,U3,U4,U5 > t3;
  293. ///
  294. public:
  295. typedef typename apply_wrap3<
  296. f_
  297. , typename t1::type, typename t2::type, typename t3::type
  298. >::type type;
  299. };
  300. };
  301. namespace aux {
  302. template<
  303. typename F, typename T1, typename T2, typename T3
  304. >
  305. aux::yes_tag
  306. is_bind_helper(bind3< F,T1,T2,T3 >*);
  307. } // namespace aux
  308. BOOST_MPL_AUX_ARITY_SPEC(4, bind3)
  309. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(4, bind3)
  310. namespace aux {
  311. template<>
  312. struct bind_chooser<3>
  313. {
  314. template<
  315. typename F, typename T1, typename T2, typename T3, typename T4
  316. , typename T5
  317. >
  318. struct result_
  319. {
  320. typedef bind3< F,T1,T2,T3 > type;
  321. };
  322. };
  323. } // namespace aux
  324. template<
  325. typename F, typename T1, typename T2, typename T3, typename T4
  326. >
  327. struct bind4
  328. {
  329. template<
  330. typename U1 = na, typename U2 = na, typename U3 = na
  331. , typename U4 = na, typename U5 = na
  332. >
  333. struct apply
  334. {
  335. private:
  336. typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0;
  337. typedef typename r0::type a0;
  338. typedef typename r0::next n1;
  339. typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_;
  340. ///
  341. typedef aux::replace_unnamed_arg< T1,n1 > r1;
  342. typedef typename r1::type a1;
  343. typedef typename r1::next n2;
  344. typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1;
  345. ///
  346. typedef aux::replace_unnamed_arg< T2,n2 > r2;
  347. typedef typename r2::type a2;
  348. typedef typename r2::next n3;
  349. typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2;
  350. ///
  351. typedef aux::replace_unnamed_arg< T3,n3 > r3;
  352. typedef typename r3::type a3;
  353. typedef typename r3::next n4;
  354. typedef aux::resolve_bind_arg< a3,U1,U2,U3,U4,U5 > t3;
  355. ///
  356. typedef aux::replace_unnamed_arg< T4,n4 > r4;
  357. typedef typename r4::type a4;
  358. typedef typename r4::next n5;
  359. typedef aux::resolve_bind_arg< a4,U1,U2,U3,U4,U5 > t4;
  360. ///
  361. public:
  362. typedef typename apply_wrap4<
  363. f_
  364. , typename t1::type, typename t2::type, typename t3::type
  365. , typename t4::type
  366. >::type type;
  367. };
  368. };
  369. namespace aux {
  370. template<
  371. typename F, typename T1, typename T2, typename T3, typename T4
  372. >
  373. aux::yes_tag
  374. is_bind_helper(bind4< F,T1,T2,T3,T4 >*);
  375. } // namespace aux
  376. BOOST_MPL_AUX_ARITY_SPEC(5, bind4)
  377. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(5, bind4)
  378. namespace aux {
  379. template<>
  380. struct bind_chooser<4>
  381. {
  382. template<
  383. typename F, typename T1, typename T2, typename T3, typename T4
  384. , typename T5
  385. >
  386. struct result_
  387. {
  388. typedef bind4< F,T1,T2,T3,T4 > type;
  389. };
  390. };
  391. } // namespace aux
  392. template<
  393. typename F, typename T1, typename T2, typename T3, typename T4
  394. , typename T5
  395. >
  396. struct bind5
  397. {
  398. template<
  399. typename U1 = na, typename U2 = na, typename U3 = na
  400. , typename U4 = na, typename U5 = na
  401. >
  402. struct apply
  403. {
  404. private:
  405. typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0;
  406. typedef typename r0::type a0;
  407. typedef typename r0::next n1;
  408. typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_;
  409. ///
  410. typedef aux::replace_unnamed_arg< T1,n1 > r1;
  411. typedef typename r1::type a1;
  412. typedef typename r1::next n2;
  413. typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1;
  414. ///
  415. typedef aux::replace_unnamed_arg< T2,n2 > r2;
  416. typedef typename r2::type a2;
  417. typedef typename r2::next n3;
  418. typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2;
  419. ///
  420. typedef aux::replace_unnamed_arg< T3,n3 > r3;
  421. typedef typename r3::type a3;
  422. typedef typename r3::next n4;
  423. typedef aux::resolve_bind_arg< a3,U1,U2,U3,U4,U5 > t3;
  424. ///
  425. typedef aux::replace_unnamed_arg< T4,n4 > r4;
  426. typedef typename r4::type a4;
  427. typedef typename r4::next n5;
  428. typedef aux::resolve_bind_arg< a4,U1,U2,U3,U4,U5 > t4;
  429. ///
  430. typedef aux::replace_unnamed_arg< T5,n5 > r5;
  431. typedef typename r5::type a5;
  432. typedef typename r5::next n6;
  433. typedef aux::resolve_bind_arg< a5,U1,U2,U3,U4,U5 > t5;
  434. ///
  435. public:
  436. typedef typename apply_wrap5<
  437. f_
  438. , typename t1::type, typename t2::type, typename t3::type
  439. , typename t4::type, typename t5::type
  440. >::type type;
  441. };
  442. };
  443. namespace aux {
  444. template<
  445. typename F, typename T1, typename T2, typename T3, typename T4
  446. , typename T5
  447. >
  448. aux::yes_tag
  449. is_bind_helper(bind5< F,T1,T2,T3,T4,T5 >*);
  450. } // namespace aux
  451. BOOST_MPL_AUX_ARITY_SPEC(6, bind5)
  452. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(6, bind5)
  453. namespace aux {
  454. template<>
  455. struct bind_chooser<5>
  456. {
  457. template<
  458. typename F, typename T1, typename T2, typename T3, typename T4
  459. , typename T5
  460. >
  461. struct result_
  462. {
  463. typedef bind5< F,T1,T2,T3,T4,T5 > type;
  464. };
  465. };
  466. } // namespace aux
  467. namespace aux {
  468. template< typename T >
  469. struct is_bind_arg
  470. {
  471. BOOST_STATIC_CONSTANT(bool, value = true);
  472. };
  473. template<>
  474. struct is_bind_arg<na>
  475. {
  476. BOOST_STATIC_CONSTANT(bool, value = false);
  477. };
  478. template<
  479. typename T1, typename T2, typename T3, typename T4, typename T5
  480. >
  481. struct bind_count_args
  482. {
  483. BOOST_STATIC_CONSTANT(int, value =
  484. is_bind_arg<T1>::value + is_bind_arg<T2>::value
  485. + is_bind_arg<T3>::value + is_bind_arg<T4>::value
  486. + is_bind_arg<T5>::value
  487. );
  488. };
  489. }
  490. template<
  491. typename F, typename T1, typename T2, typename T3, typename T4
  492. , typename T5
  493. >
  494. struct bind
  495. : aux::bind_chooser<
  496. aux::bind_count_args< T1,T2,T3,T4,T5 >::value
  497. >::template result_< F,T1,T2,T3,T4,T5 >::type
  498. {
  499. };
  500. BOOST_MPL_AUX_ARITY_SPEC(
  501. 6
  502. , bind
  503. )
  504. BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(
  505. 6
  506. , bind
  507. )
  508. }}