/extlibs/Boost/include/boost/bind/bind.hpp

https://bitbucket.org/hugoruscitti/pilascpp · C++ Header · 1751 lines · 1272 code · 435 blank · 44 comment · 29 complexity · 4cf4eaf85a7a37c277e2c0b373dba7da MD5 · raw file

Large files are truncated click here to view the full file

  1. #ifndef BOOST_BIND_BIND_HPP_INCLUDED
  2. #define BOOST_BIND_BIND_HPP_INCLUDED
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. //
  8. // bind.hpp - binds function objects to arguments
  9. //
  10. // Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd.
  11. // Copyright (c) 2001 David Abrahams
  12. // Copyright (c) 2005 Peter Dimov
  13. //
  14. // Distributed under the Boost Software License, Version 1.0. (See
  15. // accompanying file LICENSE_1_0.txt or copy at
  16. // http://www.boost.org/LICENSE_1_0.txt)
  17. //
  18. // See http://www.boost.org/libs/bind/bind.html for documentation.
  19. //
  20. #include <boost/config.hpp>
  21. #include <boost/ref.hpp>
  22. #include <boost/mem_fn.hpp>
  23. #include <boost/type.hpp>
  24. #include <boost/is_placeholder.hpp>
  25. #include <boost/bind/arg.hpp>
  26. #include <boost/detail/workaround.hpp>
  27. #include <boost/visit_each.hpp>
  28. // Borland-specific bug, visit_each() silently fails to produce code
  29. #if defined(__BORLANDC__)
  30. # define BOOST_BIND_VISIT_EACH boost::visit_each
  31. #else
  32. # define BOOST_BIND_VISIT_EACH visit_each
  33. #endif
  34. #include <boost/bind/storage.hpp>
  35. #ifdef BOOST_MSVC
  36. # pragma warning(push)
  37. # pragma warning(disable: 4512) // assignment operator could not be generated
  38. #endif
  39. namespace boost
  40. {
  41. template<class T> class weak_ptr;
  42. namespace _bi // implementation details
  43. {
  44. // result_traits
  45. template<class R, class F> struct result_traits
  46. {
  47. typedef R type;
  48. };
  49. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
  50. struct unspecified {};
  51. template<class F> struct result_traits<unspecified, F>
  52. {
  53. typedef typename F::result_type type;
  54. };
  55. template<class F> struct result_traits< unspecified, reference_wrapper<F> >
  56. {
  57. typedef typename F::result_type type;
  58. };
  59. #endif
  60. // ref_compare
  61. template<class T> bool ref_compare( T const & a, T const & b, long )
  62. {
  63. return a == b;
  64. }
  65. template<int I> bool ref_compare( arg<I> const &, arg<I> const &, int )
  66. {
  67. return true;
  68. }
  69. template<int I> bool ref_compare( arg<I> (*) (), arg<I> (*) (), int )
  70. {
  71. return true;
  72. }
  73. template<class T> bool ref_compare( reference_wrapper<T> const & a, reference_wrapper<T> const & b, int )
  74. {
  75. return a.get_pointer() == b.get_pointer();
  76. }
  77. // bind_t forward declaration for listN
  78. template<class R, class F, class L> class bind_t;
  79. template<class R, class F, class L> bool ref_compare( bind_t<R, F, L> const & a, bind_t<R, F, L> const & b, int )
  80. {
  81. return a.compare( b );
  82. }
  83. // value
  84. template<class T> class value
  85. {
  86. public:
  87. value(T const & t): t_(t) {}
  88. T & get() { return t_; }
  89. T const & get() const { return t_; }
  90. bool operator==(value const & rhs) const
  91. {
  92. return t_ == rhs.t_;
  93. }
  94. private:
  95. T t_;
  96. };
  97. // ref_compare for weak_ptr
  98. template<class T> bool ref_compare( value< weak_ptr<T> > const & a, value< weak_ptr<T> > const & b, int )
  99. {
  100. return !(a.get() < b.get()) && !(b.get() < a.get());
  101. }
  102. // type
  103. template<class T> class type {};
  104. // unwrap
  105. template<class F> struct unwrapper
  106. {
  107. static inline F & unwrap( F & f, long )
  108. {
  109. return f;
  110. }
  111. template<class F2> static inline F2 & unwrap( reference_wrapper<F2> rf, int )
  112. {
  113. return rf.get();
  114. }
  115. template<class R, class T> static inline _mfi::dm<R, T> unwrap( R T::* pm, int )
  116. {
  117. return _mfi::dm<R, T>( pm );
  118. }
  119. };
  120. // listN
  121. class list0
  122. {
  123. public:
  124. list0() {}
  125. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  126. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  127. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  128. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> & b) const { return b.eval(*this); }
  129. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> const & b) const { return b.eval(*this); }
  130. template<class R, class F, class A> R operator()(type<R>, F & f, A &, long)
  131. {
  132. return unwrapper<F>::unwrap(f, 0)();
  133. }
  134. template<class R, class F, class A> R operator()(type<R>, F const & f, A &, long) const
  135. {
  136. return unwrapper<F const>::unwrap(f, 0)();
  137. }
  138. template<class F, class A> void operator()(type<void>, F & f, A &, int)
  139. {
  140. unwrapper<F>::unwrap(f, 0)();
  141. }
  142. template<class F, class A> void operator()(type<void>, F const & f, A &, int) const
  143. {
  144. unwrapper<F const>::unwrap(f, 0)();
  145. }
  146. template<class V> void accept(V &) const
  147. {
  148. }
  149. bool operator==(list0 const &) const
  150. {
  151. return true;
  152. }
  153. };
  154. #ifdef BOOST_MSVC
  155. // MSVC is bright enough to realise that the parameter rhs
  156. // in operator==may be unused for some template argument types:
  157. #pragma warning(push)
  158. #pragma warning(disable:4100)
  159. #endif
  160. template< class A1 > class list1: private storage1< A1 >
  161. {
  162. private:
  163. typedef storage1< A1 > base_type;
  164. public:
  165. explicit list1( A1 a1 ): base_type( a1 ) {}
  166. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  167. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  168. template<class T> T & operator[] ( _bi::value<T> & v ) const { return v.get(); }
  169. template<class T> T const & operator[] ( _bi::value<T> const & v ) const { return v.get(); }
  170. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  171. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> & b) const { return b.eval(*this); }
  172. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> const & b) const { return b.eval(*this); }
  173. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  174. {
  175. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_]);
  176. }
  177. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  178. {
  179. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_]);
  180. }
  181. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  182. {
  183. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_]);
  184. }
  185. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  186. {
  187. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_]);
  188. }
  189. template<class V> void accept(V & v) const
  190. {
  191. base_type::accept(v);
  192. }
  193. bool operator==(list1 const & rhs) const
  194. {
  195. return ref_compare(base_type::a1_, rhs.a1_, 0);
  196. }
  197. };
  198. struct logical_and;
  199. struct logical_or;
  200. template< class A1, class A2 > class list2: private storage2< A1, A2 >
  201. {
  202. private:
  203. typedef storage2< A1, A2 > base_type;
  204. public:
  205. list2( A1 a1, A2 a2 ): base_type( a1, a2 ) {}
  206. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  207. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  208. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  209. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  210. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  211. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  212. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  213. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> & b) const { return b.eval(*this); }
  214. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> const & b) const { return b.eval(*this); }
  215. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  216. {
  217. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
  218. }
  219. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  220. {
  221. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
  222. }
  223. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  224. {
  225. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
  226. }
  227. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  228. {
  229. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
  230. }
  231. template<class A> bool operator()( type<bool>, logical_and & /*f*/, A & a, int )
  232. {
  233. return a[ base_type::a1_ ] && a[ base_type::a2_ ];
  234. }
  235. template<class A> bool operator()( type<bool>, logical_and const & /*f*/, A & a, int ) const
  236. {
  237. return a[ base_type::a1_ ] && a[ base_type::a2_ ];
  238. }
  239. template<class A> bool operator()( type<bool>, logical_or & /*f*/, A & a, int )
  240. {
  241. return a[ base_type::a1_ ] || a[ base_type::a2_ ];
  242. }
  243. template<class A> bool operator()( type<bool>, logical_or const & /*f*/, A & a, int ) const
  244. {
  245. return a[ base_type::a1_ ] || a[ base_type::a2_ ];
  246. }
  247. template<class V> void accept(V & v) const
  248. {
  249. base_type::accept(v);
  250. }
  251. bool operator==(list2 const & rhs) const
  252. {
  253. return ref_compare(base_type::a1_, rhs.a1_, 0) && ref_compare(base_type::a2_, rhs.a2_, 0);
  254. }
  255. };
  256. template< class A1, class A2, class A3 > class list3: private storage3< A1, A2, A3 >
  257. {
  258. private:
  259. typedef storage3< A1, A2, A3 > base_type;
  260. public:
  261. list3( A1 a1, A2 a2, A3 a3 ): base_type( a1, a2, a3 ) {}
  262. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  263. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  264. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  265. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  266. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  267. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  268. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  269. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  270. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  271. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> & b) const { return b.eval(*this); }
  272. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> const & b) const { return b.eval(*this); }
  273. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  274. {
  275. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
  276. }
  277. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  278. {
  279. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
  280. }
  281. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  282. {
  283. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
  284. }
  285. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  286. {
  287. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
  288. }
  289. template<class V> void accept(V & v) const
  290. {
  291. base_type::accept(v);
  292. }
  293. bool operator==(list3 const & rhs) const
  294. {
  295. return
  296. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  297. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  298. ref_compare( base_type::a3_, rhs.a3_, 0 );
  299. }
  300. };
  301. template< class A1, class A2, class A3, class A4 > class list4: private storage4< A1, A2, A3, A4 >
  302. {
  303. private:
  304. typedef storage4< A1, A2, A3, A4 > base_type;
  305. public:
  306. list4( A1 a1, A2 a2, A3 a3, A4 a4 ): base_type( a1, a2, a3, a4 ) {}
  307. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  308. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  309. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  310. A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
  311. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  312. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  313. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  314. A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
  315. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  316. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  317. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  318. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> & b) const { return b.eval(*this); }
  319. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> const & b) const { return b.eval(*this); }
  320. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  321. {
  322. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]);
  323. }
  324. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  325. {
  326. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]);
  327. }
  328. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  329. {
  330. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]);
  331. }
  332. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  333. {
  334. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]);
  335. }
  336. template<class V> void accept(V & v) const
  337. {
  338. base_type::accept(v);
  339. }
  340. bool operator==(list4 const & rhs) const
  341. {
  342. return
  343. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  344. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  345. ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
  346. ref_compare( base_type::a4_, rhs.a4_, 0 );
  347. }
  348. };
  349. template< class A1, class A2, class A3, class A4, class A5 > class list5: private storage5< A1, A2, A3, A4, A5 >
  350. {
  351. private:
  352. typedef storage5< A1, A2, A3, A4, A5 > base_type;
  353. public:
  354. list5( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 ): base_type( a1, a2, a3, a4, a5 ) {}
  355. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  356. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  357. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  358. A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
  359. A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
  360. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  361. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  362. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  363. A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
  364. A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
  365. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  366. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  367. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  368. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> & b) const { return b.eval(*this); }
  369. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> const & b) const { return b.eval(*this); }
  370. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  371. {
  372. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]);
  373. }
  374. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  375. {
  376. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]);
  377. }
  378. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  379. {
  380. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]);
  381. }
  382. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  383. {
  384. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]);
  385. }
  386. template<class V> void accept(V & v) const
  387. {
  388. base_type::accept(v);
  389. }
  390. bool operator==(list5 const & rhs) const
  391. {
  392. return
  393. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  394. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  395. ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
  396. ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
  397. ref_compare( base_type::a5_, rhs.a5_, 0 );
  398. }
  399. };
  400. template<class A1, class A2, class A3, class A4, class A5, class A6> class list6: private storage6< A1, A2, A3, A4, A5, A6 >
  401. {
  402. private:
  403. typedef storage6< A1, A2, A3, A4, A5, A6 > base_type;
  404. public:
  405. list6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6 ): base_type( a1, a2, a3, a4, a5, a6 ) {}
  406. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  407. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  408. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  409. A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
  410. A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
  411. A6 operator[] (boost::arg<6>) const { return base_type::a6_; }
  412. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  413. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  414. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  415. A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
  416. A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
  417. A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; }
  418. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  419. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  420. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  421. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> & b) const { return b.eval(*this); }
  422. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> const & b) const { return b.eval(*this); }
  423. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  424. {
  425. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_]);
  426. }
  427. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  428. {
  429. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_]);
  430. }
  431. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  432. {
  433. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_]);
  434. }
  435. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  436. {
  437. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_]);
  438. }
  439. template<class V> void accept(V & v) const
  440. {
  441. base_type::accept(v);
  442. }
  443. bool operator==(list6 const & rhs) const
  444. {
  445. return
  446. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  447. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  448. ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
  449. ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
  450. ref_compare( base_type::a5_, rhs.a5_, 0 ) &&
  451. ref_compare( base_type::a6_, rhs.a6_, 0 );
  452. }
  453. };
  454. template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> class list7: private storage7< A1, A2, A3, A4, A5, A6, A7 >
  455. {
  456. private:
  457. typedef storage7< A1, A2, A3, A4, A5, A6, A7 > base_type;
  458. public:
  459. list7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7 ): base_type( a1, a2, a3, a4, a5, a6, a7 ) {}
  460. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  461. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  462. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  463. A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
  464. A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
  465. A6 operator[] (boost::arg<6>) const { return base_type::a6_; }
  466. A7 operator[] (boost::arg<7>) const { return base_type::a7_; }
  467. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  468. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  469. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  470. A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
  471. A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
  472. A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; }
  473. A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; }
  474. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  475. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  476. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  477. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> & b) const { return b.eval(*this); }
  478. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> const & b) const { return b.eval(*this); }
  479. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  480. {
  481. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_]);
  482. }
  483. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  484. {
  485. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_]);
  486. }
  487. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  488. {
  489. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_]);
  490. }
  491. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  492. {
  493. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_]);
  494. }
  495. template<class V> void accept(V & v) const
  496. {
  497. base_type::accept(v);
  498. }
  499. bool operator==(list7 const & rhs) const
  500. {
  501. return
  502. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  503. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  504. ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
  505. ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
  506. ref_compare( base_type::a5_, rhs.a5_, 0 ) &&
  507. ref_compare( base_type::a6_, rhs.a6_, 0 ) &&
  508. ref_compare( base_type::a7_, rhs.a7_, 0 );
  509. }
  510. };
  511. template< class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > class list8: private storage8< A1, A2, A3, A4, A5, A6, A7, A8 >
  512. {
  513. private:
  514. typedef storage8< A1, A2, A3, A4, A5, A6, A7, A8 > base_type;
  515. public:
  516. list8( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8 ): base_type( a1, a2, a3, a4, a5, a6, a7, a8 ) {}
  517. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  518. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  519. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  520. A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
  521. A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
  522. A6 operator[] (boost::arg<6>) const { return base_type::a6_; }
  523. A7 operator[] (boost::arg<7>) const { return base_type::a7_; }
  524. A8 operator[] (boost::arg<8>) const { return base_type::a8_; }
  525. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  526. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  527. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  528. A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
  529. A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
  530. A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; }
  531. A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; }
  532. A8 operator[] (boost::arg<8> (*) ()) const { return base_type::a8_; }
  533. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  534. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  535. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  536. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> & b) const { return b.eval(*this); }
  537. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> const & b) const { return b.eval(*this); }
  538. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  539. {
  540. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_]);
  541. }
  542. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  543. {
  544. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_]);
  545. }
  546. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  547. {
  548. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_]);
  549. }
  550. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  551. {
  552. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_]);
  553. }
  554. template<class V> void accept(V & v) const
  555. {
  556. base_type::accept(v);
  557. }
  558. bool operator==(list8 const & rhs) const
  559. {
  560. return
  561. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  562. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  563. ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
  564. ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
  565. ref_compare( base_type::a5_, rhs.a5_, 0 ) &&
  566. ref_compare( base_type::a6_, rhs.a6_, 0 ) &&
  567. ref_compare( base_type::a7_, rhs.a7_, 0 ) &&
  568. ref_compare( base_type::a8_, rhs.a8_, 0 );
  569. }
  570. };
  571. template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> class list9: private storage9< A1, A2, A3, A4, A5, A6, A7, A8, A9 >
  572. {
  573. private:
  574. typedef storage9< A1, A2, A3, A4, A5, A6, A7, A8, A9 > base_type;
  575. public:
  576. list9( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9 ): base_type( a1, a2, a3, a4, a5, a6, a7, a8, a9 ) {}
  577. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  578. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  579. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  580. A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
  581. A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
  582. A6 operator[] (boost::arg<6>) const { return base_type::a6_; }
  583. A7 operator[] (boost::arg<7>) const { return base_type::a7_; }
  584. A8 operator[] (boost::arg<8>) const { return base_type::a8_; }
  585. A9 operator[] (boost::arg<9>) const { return base_type::a9_; }
  586. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  587. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  588. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  589. A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
  590. A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
  591. A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; }
  592. A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; }
  593. A8 operator[] (boost::arg<8> (*) ()) const { return base_type::a8_; }
  594. A9 operator[] (boost::arg<9> (*) ()) const { return base_type::a9_; }
  595. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  596. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  597. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  598. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> & b) const { return b.eval(*this); }
  599. template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> const & b) const { return b.eval(*this); }
  600. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  601. {
  602. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_], a[base_type::a9_]);
  603. }
  604. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  605. {
  606. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_], a[base_type::a9_]);
  607. }
  608. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  609. {
  610. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_], a[base_type::a9_]);
  611. }
  612. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  613. {
  614. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_], a[base_type::a9_]);
  615. }
  616. template<class V> void accept(V & v) const
  617. {
  618. base_type::accept(v);
  619. }
  620. bool operator==(list9 const & rhs) const
  621. {
  622. return
  623. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  624. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  625. ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
  626. ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
  627. ref_compare( base_type::a5_, rhs.a5_, 0 ) &&
  628. ref_compare( base_type::a6_, rhs.a6_, 0 ) &&
  629. ref_compare( base_type::a7_, rhs.a7_, 0 ) &&
  630. ref_compare( base_type::a8_, rhs.a8_, 0 ) &&
  631. ref_compare( base_type::a9_, rhs.a9_, 0 );
  632. }
  633. };
  634. #ifdef BOOST_MSVC
  635. #pragma warning(pop)
  636. #endif
  637. // bind_t
  638. #ifndef BOOST_NO_VOID_RETURNS
  639. template<class R, class F, class L> class bind_t
  640. {
  641. public:
  642. typedef bind_t this_type;
  643. bind_t(F f, L const & l): f_(f), l_(l) {}
  644. #define BOOST_BIND_RETURN return
  645. #include <boost/bind/bind_template.hpp>
  646. #undef BOOST_BIND_RETURN
  647. };
  648. #else
  649. template<class R> struct bind_t_generator
  650. {
  651. template<class F, class L> class implementation
  652. {
  653. public:
  654. typedef implementation this_type;
  655. implementation(F f, L const & l): f_(f), l_(l) {}
  656. #define BOOST_BIND_RETURN return
  657. #include <boost/bind/bind_template.hpp>
  658. #undef BOOST_BIND_RETURN
  659. };
  660. };
  661. template<> struct bind_t_generator<void>
  662. {
  663. template<class F, class L> class implementation
  664. {
  665. private:
  666. typedef void R;
  667. public:
  668. typedef implementation this_type;
  669. implementation(F f, L const & l): f_(f), l_(l) {}
  670. #define BOOST_BIND_RETURN
  671. #include <boost/bind/bind_template.hpp>
  672. #undef BOOST_BIND_RETURN
  673. };
  674. };
  675. template<class R2, class F, class L> class bind_t: public bind_t_generator<R2>::BOOST_NESTED_TEMPLATE implementation<F, L>
  676. {
  677. public:
  678. bind_t(F f, L const & l): bind_t_generator<R2>::BOOST_NESTED_TEMPLATE implementation<F, L>(f, l) {}
  679. };
  680. #endif
  681. // function_equal
  682. #ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
  683. // put overloads in _bi, rely on ADL
  684. # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  685. template<class R, class F, class L> bool function_equal( bind_t<R, F, L> const & a, bind_t<R, F, L> const & b )
  686. {
  687. return a.compare(b);
  688. }
  689. # else
  690. template<class R, class F, class L> bool function_equal_impl( bind_t<R, F, L> const & a, bind_t<R, F, L> const & b, int )
  691. {
  692. return a.compare(b);
  693. }
  694. # endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  695. #else // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
  696. // put overloads in boost
  697. } // namespace _bi
  698. # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  699. template<class R, class F, class L> bool function_equal( _bi::bind_t<R, F, L> const & a, _bi::bind_t<R, F, L> const & b )
  700. {
  701. return a.compare(b);
  702. }
  703. # else
  704. template<class R, class F, class L> bool function_equal_impl( _bi::bind_t<R, F, L> const & a, _bi::bind_t<R, F, L> const & b, int )
  705. {
  706. return a.compare(b);
  707. }
  708. # endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  709. namespace _bi
  710. {
  711. #endif // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
  712. // add_value
  713. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530)
  714. #if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x582) )
  715. template<class T> struct add_value
  716. {
  717. typedef _bi::value<T> type;
  718. };
  719. #else
  720. template< class T, int I > struct add_value_2
  721. {
  722. typedef boost::arg<I> type;
  723. };
  724. template< class T > struct add_value_2< T, 0 >
  725. {
  726. typedef _bi::value< T > type;
  727. };
  728. template<class T> struct add_value
  729. {
  730. typedef typename add_value_2< T, boost::is_placeholder< T >::value >::type type;
  731. };
  732. #endif
  733. template<class T> struct add_value< value<T> >
  734. {
  735. typedef _bi::value<T> type;
  736. };
  737. template<class T> struct add_value< reference_wrapper<T> >
  738. {
  739. typedef reference_wrapper<T> type;
  740. };
  741. template<int I> struct add_value< arg<I> >
  742. {
  743. typedef boost::arg<I> type;
  744. };
  745. template<int I> struct add_value< arg<I> (*) () >
  746. {
  747. typedef boost::arg<I> (*type) ();
  748. };
  749. template<class R, class F, class L> struct add_value< bind_t<R, F, L> >
  750. {
  751. typedef bind_t<R, F, L> type;
  752. };
  753. #else
  754. template<int I> struct _avt_0;
  755. template<> struct _avt_0<1>
  756. {
  757. template<class T> struct inner
  758. {
  759. typedef T type;
  760. };
  761. };
  762. template<> struct _avt_0<2>
  763. {
  764. template<class T> struct inner
  765. {
  766. typedef value<T> type;
  767. };
  768. };
  769. typedef char (&_avt_r1) [1];
  770. typedef char (&_avt_r2) [2];
  771. template<class T> _avt_r1 _avt_f(value<T>);
  772. template<class T> _avt_r1 _avt_f(reference_wrapper<T>);
  773. template<int I> _avt_r1 _avt_f(arg<I>);
  774. template<int I> _avt_r1 _avt_f(arg<I> (*) ());
  775. template<class R, class F, class L> _avt_r1 _avt_f(bind_t<R, F, L>);
  776. _avt_r2 _avt_f(...);
  777. template<class T> struct add_value
  778. {
  779. static T t();
  780. typedef typename _avt_0<sizeof(_avt_f(t()))>::template inner<T>::type type;
  781. };
  782. #endif
  783. // list_av_N
  784. template<class A1> struct list_av_1
  785. {
  786. typedef typename add_value<A1>::type B1;
  787. typedef list1<B1> type;
  788. };
  789. template<class A1, class A2> struct list_av_2
  790. {
  791. typedef typename add_value<A1>::type B1;
  792. typedef typename add_value<A2>::type B2;
  793. typedef list2<B1, B2> type;
  794. };
  795. template<class A1, class A2, class A3> struct list_av_3
  796. {
  797. typedef typename add_value<A1>::type B1;
  798. typedef typename add_value<A2>::type B2;
  799. typedef typename add_value<A3>::type B3;
  800. typedef list3<B1, B2, B3> type;
  801. };
  802. template<class A1, class A2, class A3, class A4> struct list_av_4
  803. {
  804. typedef typename add_value<A1>::type B1;
  805. typedef typename add_value<A2>::type B2;
  806. typedef typename add_value<A3>::type B3;
  807. typedef typename add_value<A4>::type B4;
  808. typedef list4<B1, B2, B3, B4> type;
  809. };
  810. template<class A1, class A2, class A3, class A4, class A5> struct list_av_5
  811. {
  812. typedef typename add_value<A1>::type B1;
  813. typedef typename add_value<A2>::type B2;
  814. typedef typename add_value<A3>::type B3;
  815. typedef typename add_value<A4>::type B4;
  816. typedef typename add_value<A5>::type B5;
  817. typedef list5<B1, B2, B3, B4, B5> type;
  818. };
  819. template<class A1, class A2, class A3, class A4, class A5, class A6> struct list_av_6
  820. {
  821. typedef typename add_value<A1>::type B1;
  822. typedef typename add_value<A2>::type B2;
  823. typedef typename add_value<A3>::type B3;
  824. typedef typename add_value<A4>::type B4;
  825. typedef typename add_value<A5>::type B5;
  826. typedef typename add_value<A6>::type B6;
  827. typedef list6<B1, B2, B3, B4, B5, B6> type;
  828. };
  829. template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct list_av_7
  830. {
  831. typedef typename add_value<A1>::type B1;
  832. typedef typename add_value<A2>::type B2;
  833. typedef typename add_value<A3>::type B3;
  834. typedef typename add_value<A4>::type B4;
  835. typedef typename add_value<A5>::type B5;
  836. typedef typename add_value<A6>::type B6;
  837. typedef typename add_value<A7>::type B7;
  838. typedef list7<B1, B2, B3, B4, B5, B6, B7> type;
  839. };
  840. template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct list_av_8
  841. {
  842. typedef typename add_value<A1>::type B1;
  843. typedef typename add_value<A2>::type B2;
  844. typedef typename add_value<A3>::type B3;
  845. typedef typename add_value<A4>::type B4;
  846. typedef typename add_value<A5>::type B5;
  847. typedef typename add_value<A6>::type B6;
  848. typedef typename add_value<A7>::type B7;
  849. typedef typename add_value<A8>::type B8;
  850. typedef list8<B1, B2, B3, B4, B5, B6, B7, B8> type;
  851. };
  852. template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> struct list_av_9
  853. {
  854. typedef typename add_value<A1>::type B1;
  855. typedef typename add_value<A2>::type B2;
  856. typedef typename add_value<A3>::type B3;
  857. typedef typename add_value<A4>::type B4;
  858. typedef typename add_value<A5>::type B5;
  859. typedef typename add_value<A6>::type B6;
  860. typedef typename add_value<A7>::type B7;
  861. typedef typename add_value<A8>::type B8;
  862. typedef typename add_value<A9>::type B9;
  863. typedef list9<B1, B2, B3, B4, B5, B6, B7, B8, B9> type;
  864. };
  865. // operator!
  866. struct logical_not
  867. {
  868. template<class V> bool operator()(V const & v) const { return !v; }
  869. };
  870. template<class R, class F, class L>
  871. bind_t< bool, logical_not, list1< bind_t<R, F, L> > >
  872. operator! (bind_t<R, F, L> const & f)
  873. {
  874. typedef list1< bind_t<R, F, L> > list_type;
  875. return bind_t<bool, logical_not, list_type> ( logical_not(), list_type(f) );
  876. }
  877. // relational operators
  878. #define BOOST_BIND_OPERATOR( op, name ) \
  879. \
  880. struct name \
  881. { \
  882. template<class V, class W> bool operator()(V const & v, W const & w) const { return v op w; } \
  883. }; \
  884. \
  885. template<class R, class F, class L, class A2> \
  886. bind_t< bool, name, list2< bind_t<R, F, L>, typename add_value<A2>::type > > \
  887. operator op (bind_t<R, F, L> const & f, A2 a2) \
  888. { \
  889. typedef typename add_value<A2>::type B2; \
  890. typedef list2< bind_t<R, F, L>, B2> list_type; \
  891. return bind_t<bool, name, list_type> ( name(), list_type(f, a2) ); \
  892. }
  893. BOOST_BIND_OPERATOR( ==, equal )
  894. BOOST_BIND_OPERATOR( !=, not_equal )
  895. BOOST_BIND_OPERATOR( <, less )
  896. BOOST_BIND_OPERATOR( <=, less_equal )
  897. BOOST_BIND_OPERATOR( >, greater )
  898. BOOST_BIND_OPERATOR( >=, greater_equal )
  899. BOOST_BIND_OPERATOR( &&, logical_and )
  900. BOOST_BIND_OPERATOR( ||, logical_or )
  901. #undef BOOST_BIND_OPERATOR
  902. #if defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3)
  903. // resolve ambiguity with rel_ops
  904. #define BOOST_BIND_OPERATOR( op, name ) \
  905. \
  906. template<class R, class F, class L> \
  907. bind_t< bool, name, list2< bind_t<R, F, L>, bind_t<R, F, L> > > \
  908. operator op (bind_t<R, F, L> const & f, bind_t<R, F, L> const & g) \
  909. { \
  910. typedef list2< bind_t<R, F, L>, bind_t<R, F, L> > list_type; \
  911. return bind_t<bool, name, list_type> ( name(), list_type(f, g) ); \
  912. }
  913. BOOST_BIND_OPERATOR( !=, not_equal )
  914. BOOST_BIND_OPERATOR( <=, less_equal )
  915. BOOST_BIND_OPERATOR( >, greater )
  916. BOOST_BIND_OPERATOR( >=, greater_equal )
  917. #endif
  918. // visit_each, ADL
  919. #if !defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) && !defined( __BORLANDC__ ) \
  920. && !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
  921. template<class V, class T> void visit_each( V & v, value<T> const & t, int )
  922. {
  923. using boost::visit_each;
  924. BOOST_BIND_VISIT_EACH( v, t.get(), 0 );
  925. }
  926. template<class V, class R, class F, class L> void visit_each( V & v, bind_t<R, F, L> const & t, int )
  927. {
  928. t.accept( v );
  929. }
  930. #endif
  931. } // namespace _bi
  932. // visit_each, no ADL
  933. #if defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) || defined( __BORLANDC__ ) \
  934. || (defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
  935. template<class V, class T> void visit_each( V & v, _bi::value<T> const & t, int )
  936. {
  937. BOOST_BIND_VISIT_EACH( v, t.get(), 0 );
  938. }
  939. template<class V, class R, class F, class L> void visit_each( V & v, _bi::bind_t<R, F, L> const & t, int )
  940. {
  941. t.accept( v );
  942. }
  943. #endif
  944. // is_bind_expression
  945. template< class T > struct is_bind_expression
  946. {
  947. enum _vt { value = 0 };
  948. };
  949. #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
  950. template< class R, class F, class L > struct is_bind_expression< _bi::bind_t< R, F, L > >
  951. {
  952. enum _vt { value = 1 };
  953. };
  954. #endif
  955. // bind
  956. #ifndef BOOST_BIND
  957. #define BOOST_BIND bind
  958. #endif
  959. // generic function objects
  960. template<class R, class F>
  961. _bi::bind_t<R, F, _bi::list0>
  962. BOOST_BIND(F f)
  963. {
  964. typedef _bi::list0 list_type;
  965. return _bi::bind_t<R, F, list_type> (f, list_type());
  966. }
  967. template<class R, class F, class A1>
  968. _bi::bind_t<R, F, typename _bi::list_av_1<A1>::type>
  969. BOOST_BIND(F f, A1 a1)
  970. {
  971. typedef typename _bi::list_av_1<A1>::type list_type;
  972. return _bi::bind_t<R, F, list_type> (f, list_type(a1));
  973. }
  974. template<class R, class F, class A1, class A2>
  975. _bi::bind_t<R, F, typename _bi::list_av_2<A1, A2>::type>
  976. BOOST_BIND(F f, A1 a1, A2 a2)
  977. {
  978. typedef typename _bi::list_av_2<A1, A2>::type list_type;
  979. return _bi::bind_t<R, F, list_type> (f, list_type(a1, a2));
  980. }
  981. template<class R, class F, class A1, class A2, class A3>
  982. _bi::bind_t<R, F, typename _bi::list_av_3<A1, A2, A3>::type>
  983. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3)
  984. {
  985. typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
  986. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3));
  987. }
  988. template<class R, class F, class A1, class A2, class A3, class A4>
  989. _bi::bind_t<R, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
  990. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4)
  991. {
  992. typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
  993. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4));
  994. }
  995. template<class R, class F, class A1, class A2, class A3, class A4, class A5>
  996. _bi::bind_t<R, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
  997. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
  998. {
  999. typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
  1000. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
  1001. }
  1002. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6>
  1003. _bi::bind_t<R, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
  1004. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
  1005. {
  1006. typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
  1007. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
  1008. }
  1009. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
  1010. _bi::bind_t<R, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
  1011. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
  1012. {
  1013. typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
  1014. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
  1015. }
  1016. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
  1017. _bi::bind_t<R, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
  1018. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
  1019. {
  1020. typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
  1021. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
  1022. }
  1023. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
  1024. _bi::bind_t<R, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
  1025. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
  1026. {
  1027. typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
  1028. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
  1029. }
  1030. // generic function objects, alternative syntax
  1031. template<class R, class F>
  1032. _bi::bind_t<R, F, _bi::list0>
  1033. BOOST_BIND(boost::type<R>, F f)
  1034. {
  1035. typedef _bi::list0 list_type;
  1036. return _bi::bind_t<R, F, list_type> (f, list_type());
  1037. }
  1038. template<class R, class F, class A1>
  1039. _bi::bind_t<R, F, typename _bi::list_av_1<A1>::type>
  1040. BOOST_BIND(boost::type<R>, F f, A1 a1)
  1041. {
  1042. typedef typename _bi::list_av_1<A1>::type list_type;
  1043. return _bi::bind_t<R, F, list_type> (f, list_type(a1));
  1044. }
  1045. template<class R, class F, class A1, class A2>
  1046. _bi::bind_t<R, F, typename _bi::list_av_2<A1, A2>::type>
  1047. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2)
  1048. {
  1049. typedef typename _bi::list_av_2<A1, A2>::type list_type;
  1050. return _bi::bind_t<R, F, list_type> (f, list_type(a1, a2));
  1051. }
  1052. template<class R, class F, class A1, class A2, class A3>
  1053. _bi::bind_t<R, F, typename _bi::list_av_3<A1, A2, A3>::type>
  1054. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3)
  1055. {
  1056. typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
  1057. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3));
  1058. }
  1059. template<class R, class F, class A1, class A2, class A3, class A4>
  1060. _bi::bind_t<R, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
  1061. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4)
  1062. {
  1063. typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
  1064. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4));
  1065. }
  1066. template<class R, class F, class A1, class A2, class A3, class A4, class A5>
  1067. _bi::bind_t<R, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
  1068. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
  1069. {
  1070. typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
  1071. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
  1072. }
  1073. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6>
  1074. _bi::bind_t<R, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
  1075. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
  1076. {
  1077. typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
  1078. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
  1079. }
  1080. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
  1081. _bi::bind_t<R, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
  1082. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
  1083. {
  1084. typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
  1085. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
  1086. }
  1087. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
  1088. _bi::bind_t<R, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
  1089. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
  1090. {
  1091. typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
  1092. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
  1093. }
  1094. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
  1095. _bi::bind_t<R, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
  1096. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
  1097. {
  1098. typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
  1099. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
  1100. }
  1101. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
  1102. // adaptable function objects
  1103. template<class F>
  1104. _bi::bind_t<_bi::unspecified, F, _bi::list0>
  1105. BOOST_BIND(F f)
  1106. {
  1107. typedef _bi::list0 list_type;
  1108. return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type());
  1109. }
  1110. template<class F, class A1>
  1111. _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_1<A1>::type>
  1112. BOOST_BIND(F f, A1 a1)
  1113. {
  1114. typedef typename _bi::list_av_1<A1>::type list_