bind.hpp 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733
  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. template< class A1 > class list1: private storage1< A1 >
  155. {
  156. private:
  157. typedef storage1< A1 > base_type;
  158. public:
  159. explicit list1( A1 a1 ): base_type( a1 ) {}
  160. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  161. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  162. template<class T> T & operator[] ( _bi::value<T> & v ) const { return v.get(); }
  163. template<class T> T const & operator[] ( _bi::value<T> const & v ) const { return v.get(); }
  164. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  165. 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); }
  166. 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); }
  167. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  168. {
  169. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_]);
  170. }
  171. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  172. {
  173. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_]);
  174. }
  175. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  176. {
  177. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_]);
  178. }
  179. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  180. {
  181. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_]);
  182. }
  183. template<class V> void accept(V & v) const
  184. {
  185. base_type::accept(v);
  186. }
  187. bool operator==(list1 const & rhs) const
  188. {
  189. return ref_compare(base_type::a1_, rhs.a1_, 0);
  190. }
  191. };
  192. struct logical_and;
  193. struct logical_or;
  194. template< class A1, class A2 > class list2: private storage2< A1, A2 >
  195. {
  196. private:
  197. typedef storage2< A1, A2 > base_type;
  198. public:
  199. list2( A1 a1, A2 a2 ): base_type( a1, a2 ) {}
  200. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  201. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  202. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  203. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  204. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  205. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  206. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  207. 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); }
  208. 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); }
  209. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  210. {
  211. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
  212. }
  213. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  214. {
  215. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
  216. }
  217. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  218. {
  219. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
  220. }
  221. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  222. {
  223. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
  224. }
  225. template<class A> bool operator()( type<bool>, logical_and & /*f*/, A & a, int )
  226. {
  227. return a[ base_type::a1_ ] && a[ base_type::a2_ ];
  228. }
  229. template<class A> bool operator()( type<bool>, logical_and const & /*f*/, A & a, int ) const
  230. {
  231. return a[ base_type::a1_ ] && a[ base_type::a2_ ];
  232. }
  233. template<class A> bool operator()( type<bool>, logical_or & /*f*/, A & a, int )
  234. {
  235. return a[ base_type::a1_ ] || a[ base_type::a2_ ];
  236. }
  237. template<class A> bool operator()( type<bool>, logical_or const & /*f*/, A & a, int ) const
  238. {
  239. return a[ base_type::a1_ ] || a[ base_type::a2_ ];
  240. }
  241. template<class V> void accept(V & v) const
  242. {
  243. base_type::accept(v);
  244. }
  245. bool operator==(list2 const & rhs) const
  246. {
  247. return ref_compare(base_type::a1_, rhs.a1_, 0) && ref_compare(base_type::a2_, rhs.a2_, 0);
  248. }
  249. };
  250. template< class A1, class A2, class A3 > class list3: private storage3< A1, A2, A3 >
  251. {
  252. private:
  253. typedef storage3< A1, A2, A3 > base_type;
  254. public:
  255. list3( A1 a1, A2 a2, A3 a3 ): base_type( a1, a2, a3 ) {}
  256. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  257. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  258. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  259. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  260. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  261. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  262. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  263. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  264. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  265. 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); }
  266. 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); }
  267. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  268. {
  269. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
  270. }
  271. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  272. {
  273. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
  274. }
  275. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  276. {
  277. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
  278. }
  279. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  280. {
  281. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
  282. }
  283. template<class V> void accept(V & v) const
  284. {
  285. base_type::accept(v);
  286. }
  287. bool operator==(list3 const & rhs) const
  288. {
  289. return
  290. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  291. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  292. ref_compare( base_type::a3_, rhs.a3_, 0 );
  293. }
  294. };
  295. template< class A1, class A2, class A3, class A4 > class list4: private storage4< A1, A2, A3, A4 >
  296. {
  297. private:
  298. typedef storage4< A1, A2, A3, A4 > base_type;
  299. public:
  300. list4( A1 a1, A2 a2, A3 a3, A4 a4 ): base_type( a1, a2, a3, a4 ) {}
  301. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  302. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  303. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  304. A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
  305. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  306. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  307. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  308. A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
  309. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  310. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  311. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  312. 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); }
  313. 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); }
  314. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  315. {
  316. return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]);
  317. }
  318. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  319. {
  320. return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]);
  321. }
  322. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  323. {
  324. unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]);
  325. }
  326. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  327. {
  328. unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]);
  329. }
  330. template<class V> void accept(V & v) const
  331. {
  332. base_type::accept(v);
  333. }
  334. bool operator==(list4 const & rhs) const
  335. {
  336. return
  337. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  338. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  339. ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
  340. ref_compare( base_type::a4_, rhs.a4_, 0 );
  341. }
  342. };
  343. template< class A1, class A2, class A3, class A4, class A5 > class list5: private storage5< A1, A2, A3, A4, A5 >
  344. {
  345. private:
  346. typedef storage5< A1, A2, A3, A4, A5 > base_type;
  347. public:
  348. list5( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 ): base_type( a1, a2, a3, a4, a5 ) {}
  349. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  350. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  351. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  352. A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
  353. A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
  354. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  355. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  356. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  357. A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
  358. A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
  359. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  360. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  361. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  362. 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); }
  363. 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); }
  364. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  365. {
  366. 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_]);
  367. }
  368. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  369. {
  370. 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_]);
  371. }
  372. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  373. {
  374. 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_]);
  375. }
  376. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  377. {
  378. 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_]);
  379. }
  380. template<class V> void accept(V & v) const
  381. {
  382. base_type::accept(v);
  383. }
  384. bool operator==(list5 const & rhs) const
  385. {
  386. return
  387. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  388. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  389. ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
  390. ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
  391. ref_compare( base_type::a5_, rhs.a5_, 0 );
  392. }
  393. };
  394. template<class A1, class A2, class A3, class A4, class A5, class A6> class list6: private storage6< A1, A2, A3, A4, A5, A6 >
  395. {
  396. private:
  397. typedef storage6< A1, A2, A3, A4, A5, A6 > base_type;
  398. public:
  399. list6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6 ): base_type( a1, a2, a3, a4, a5, a6 ) {}
  400. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  401. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  402. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  403. A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
  404. A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
  405. A6 operator[] (boost::arg<6>) const { return base_type::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. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  413. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  414. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  415. 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); }
  416. 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); }
  417. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  418. {
  419. 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_]);
  420. }
  421. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  422. {
  423. 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_]);
  424. }
  425. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  426. {
  427. 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_]);
  428. }
  429. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  430. {
  431. 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_]);
  432. }
  433. template<class V> void accept(V & v) const
  434. {
  435. base_type::accept(v);
  436. }
  437. bool operator==(list6 const & rhs) const
  438. {
  439. return
  440. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  441. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  442. ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
  443. ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
  444. ref_compare( base_type::a5_, rhs.a5_, 0 ) &&
  445. ref_compare( base_type::a6_, rhs.a6_, 0 );
  446. }
  447. };
  448. 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 >
  449. {
  450. private:
  451. typedef storage7< A1, A2, A3, A4, A5, A6, A7 > base_type;
  452. public:
  453. list7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7 ): base_type( a1, a2, a3, a4, a5, a6, a7 ) {}
  454. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  455. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  456. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  457. A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
  458. A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
  459. A6 operator[] (boost::arg<6>) const { return base_type::a6_; }
  460. A7 operator[] (boost::arg<7>) const { return base_type::a7_; }
  461. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  462. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  463. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  464. A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
  465. A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
  466. A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; }
  467. A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; }
  468. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  469. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  470. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  471. 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); }
  472. 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); }
  473. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  474. {
  475. 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_]);
  476. }
  477. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  478. {
  479. 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_]);
  480. }
  481. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  482. {
  483. 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_]);
  484. }
  485. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  486. {
  487. 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_]);
  488. }
  489. template<class V> void accept(V & v) const
  490. {
  491. base_type::accept(v);
  492. }
  493. bool operator==(list7 const & rhs) const
  494. {
  495. return
  496. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  497. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  498. ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
  499. ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
  500. ref_compare( base_type::a5_, rhs.a5_, 0 ) &&
  501. ref_compare( base_type::a6_, rhs.a6_, 0 ) &&
  502. ref_compare( base_type::a7_, rhs.a7_, 0 );
  503. }
  504. };
  505. 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 >
  506. {
  507. private:
  508. typedef storage8< A1, A2, A3, A4, A5, A6, A7, A8 > base_type;
  509. public:
  510. 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 ) {}
  511. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  512. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  513. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  514. A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
  515. A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
  516. A6 operator[] (boost::arg<6>) const { return base_type::a6_; }
  517. A7 operator[] (boost::arg<7>) const { return base_type::a7_; }
  518. A8 operator[] (boost::arg<8>) const { return base_type::a8_; }
  519. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  520. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  521. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  522. A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
  523. A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
  524. A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; }
  525. A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; }
  526. A8 operator[] (boost::arg<8> (*) ()) const { return base_type::a8_; }
  527. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  528. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  529. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  530. 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); }
  531. 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); }
  532. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  533. {
  534. 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_]);
  535. }
  536. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  537. {
  538. 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_]);
  539. }
  540. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  541. {
  542. 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_]);
  543. }
  544. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  545. {
  546. 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_]);
  547. }
  548. template<class V> void accept(V & v) const
  549. {
  550. base_type::accept(v);
  551. }
  552. bool operator==(list8 const & rhs) const
  553. {
  554. return
  555. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  556. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  557. ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
  558. ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
  559. ref_compare( base_type::a5_, rhs.a5_, 0 ) &&
  560. ref_compare( base_type::a6_, rhs.a6_, 0 ) &&
  561. ref_compare( base_type::a7_, rhs.a7_, 0 ) &&
  562. ref_compare( base_type::a8_, rhs.a8_, 0 );
  563. }
  564. };
  565. 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 >
  566. {
  567. private:
  568. typedef storage9< A1, A2, A3, A4, A5, A6, A7, A8, A9 > base_type;
  569. public:
  570. 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 ) {}
  571. A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
  572. A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
  573. A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
  574. A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
  575. A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
  576. A6 operator[] (boost::arg<6>) const { return base_type::a6_; }
  577. A7 operator[] (boost::arg<7>) const { return base_type::a7_; }
  578. A8 operator[] (boost::arg<8>) const { return base_type::a8_; }
  579. A9 operator[] (boost::arg<9>) const { return base_type::a9_; }
  580. A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
  581. A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
  582. A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
  583. A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
  584. A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
  585. A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; }
  586. A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; }
  587. A8 operator[] (boost::arg<8> (*) ()) const { return base_type::a8_; }
  588. A9 operator[] (boost::arg<9> (*) ()) const { return base_type::a9_; }
  589. template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
  590. template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
  591. template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
  592. 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); }
  593. 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); }
  594. template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
  595. {
  596. 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_]);
  597. }
  598. template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
  599. {
  600. 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_]);
  601. }
  602. template<class F, class A> void operator()(type<void>, F & f, A & a, int)
  603. {
  604. 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_]);
  605. }
  606. template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
  607. {
  608. 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_]);
  609. }
  610. template<class V> void accept(V & v) const
  611. {
  612. base_type::accept(v);
  613. }
  614. bool operator==(list9 const & rhs) const
  615. {
  616. return
  617. ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
  618. ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
  619. ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
  620. ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
  621. ref_compare( base_type::a5_, rhs.a5_, 0 ) &&
  622. ref_compare( base_type::a6_, rhs.a6_, 0 ) &&
  623. ref_compare( base_type::a7_, rhs.a7_, 0 ) &&
  624. ref_compare( base_type::a8_, rhs.a8_, 0 ) &&
  625. ref_compare( base_type::a9_, rhs.a9_, 0 );
  626. }
  627. };
  628. // bind_t
  629. #ifndef BOOST_NO_VOID_RETURNS
  630. template<class R, class F, class L> class bind_t
  631. {
  632. public:
  633. typedef bind_t this_type;
  634. bind_t(F f, L const & l): f_(f), l_(l) {}
  635. #define BOOST_BIND_RETURN return
  636. #include <boost/bind/bind_template.hpp>
  637. #undef BOOST_BIND_RETURN
  638. };
  639. #else
  640. template<class R> struct bind_t_generator
  641. {
  642. template<class F, class L> class implementation
  643. {
  644. public:
  645. typedef implementation this_type;
  646. implementation(F f, L const & l): f_(f), l_(l) {}
  647. #define BOOST_BIND_RETURN return
  648. #include <boost/bind/bind_template.hpp>
  649. #undef BOOST_BIND_RETURN
  650. };
  651. };
  652. template<> struct bind_t_generator<void>
  653. {
  654. template<class F, class L> class implementation
  655. {
  656. private:
  657. typedef void R;
  658. public:
  659. typedef implementation this_type;
  660. implementation(F f, L const & l): f_(f), l_(l) {}
  661. #define BOOST_BIND_RETURN
  662. #include <boost/bind/bind_template.hpp>
  663. #undef BOOST_BIND_RETURN
  664. };
  665. };
  666. template<class R2, class F, class L> class bind_t: public bind_t_generator<R2>::BOOST_NESTED_TEMPLATE implementation<F, L>
  667. {
  668. public:
  669. bind_t(F f, L const & l): bind_t_generator<R2>::BOOST_NESTED_TEMPLATE implementation<F, L>(f, l) {}
  670. };
  671. #endif
  672. // function_equal
  673. #ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
  674. // put overloads in _bi, rely on ADL
  675. # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  676. template<class R, class F, class L> bool function_equal( bind_t<R, F, L> const & a, bind_t<R, F, L> const & b )
  677. {
  678. return a.compare(b);
  679. }
  680. # else
  681. 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 )
  682. {
  683. return a.compare(b);
  684. }
  685. # endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  686. #else // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
  687. // put overloads in boost
  688. } // namespace _bi
  689. # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  690. 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 )
  691. {
  692. return a.compare(b);
  693. }
  694. # else
  695. 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 )
  696. {
  697. return a.compare(b);
  698. }
  699. # endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  700. namespace _bi
  701. {
  702. #endif // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
  703. // add_value
  704. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530)
  705. #if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x582) )
  706. template<class T> struct add_value
  707. {
  708. typedef _bi::value<T> type;
  709. };
  710. #else
  711. template< class T, int I > struct add_value_2
  712. {
  713. typedef boost::arg<I> type;
  714. };
  715. template< class T > struct add_value_2< T, 0 >
  716. {
  717. typedef _bi::value< T > type;
  718. };
  719. template<class T> struct add_value
  720. {
  721. typedef typename add_value_2< T, boost::is_placeholder< T >::value >::type type;
  722. };
  723. #endif
  724. template<class T> struct add_value< value<T> >
  725. {
  726. typedef _bi::value<T> type;
  727. };
  728. template<class T> struct add_value< reference_wrapper<T> >
  729. {
  730. typedef reference_wrapper<T> type;
  731. };
  732. template<int I> struct add_value< arg<I> >
  733. {
  734. typedef boost::arg<I> type;
  735. };
  736. template<int I> struct add_value< arg<I> (*) () >
  737. {
  738. typedef boost::arg<I> (*type) ();
  739. };
  740. template<class R, class F, class L> struct add_value< bind_t<R, F, L> >
  741. {
  742. typedef bind_t<R, F, L> type;
  743. };
  744. #else
  745. template<int I> struct _avt_0;
  746. template<> struct _avt_0<1>
  747. {
  748. template<class T> struct inner
  749. {
  750. typedef T type;
  751. };
  752. };
  753. template<> struct _avt_0<2>
  754. {
  755. template<class T> struct inner
  756. {
  757. typedef value<T> type;
  758. };
  759. };
  760. typedef char (&_avt_r1) [1];
  761. typedef char (&_avt_r2) [2];
  762. template<class T> _avt_r1 _avt_f(value<T>);
  763. template<class T> _avt_r1 _avt_f(reference_wrapper<T>);
  764. template<int I> _avt_r1 _avt_f(arg<I>);
  765. template<int I> _avt_r1 _avt_f(arg<I> (*) ());
  766. template<class R, class F, class L> _avt_r1 _avt_f(bind_t<R, F, L>);
  767. _avt_r2 _avt_f(...);
  768. template<class T> struct add_value
  769. {
  770. static T t();
  771. typedef typename _avt_0<sizeof(_avt_f(t()))>::template inner<T>::type type;
  772. };
  773. #endif
  774. // list_av_N
  775. template<class A1> struct list_av_1
  776. {
  777. typedef typename add_value<A1>::type B1;
  778. typedef list1<B1> type;
  779. };
  780. template<class A1, class A2> struct list_av_2
  781. {
  782. typedef typename add_value<A1>::type B1;
  783. typedef typename add_value<A2>::type B2;
  784. typedef list2<B1, B2> type;
  785. };
  786. template<class A1, class A2, class A3> struct list_av_3
  787. {
  788. typedef typename add_value<A1>::type B1;
  789. typedef typename add_value<A2>::type B2;
  790. typedef typename add_value<A3>::type B3;
  791. typedef list3<B1, B2, B3> type;
  792. };
  793. template<class A1, class A2, class A3, class A4> struct list_av_4
  794. {
  795. typedef typename add_value<A1>::type B1;
  796. typedef typename add_value<A2>::type B2;
  797. typedef typename add_value<A3>::type B3;
  798. typedef typename add_value<A4>::type B4;
  799. typedef list4<B1, B2, B3, B4> type;
  800. };
  801. template<class A1, class A2, class A3, class A4, class A5> struct list_av_5
  802. {
  803. typedef typename add_value<A1>::type B1;
  804. typedef typename add_value<A2>::type B2;
  805. typedef typename add_value<A3>::type B3;
  806. typedef typename add_value<A4>::type B4;
  807. typedef typename add_value<A5>::type B5;
  808. typedef list5<B1, B2, B3, B4, B5> type;
  809. };
  810. template<class A1, class A2, class A3, class A4, class A5, class A6> struct list_av_6
  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 typename add_value<A6>::type B6;
  818. typedef list6<B1, B2, B3, B4, B5, B6> type;
  819. };
  820. template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct list_av_7
  821. {
  822. typedef typename add_value<A1>::type B1;
  823. typedef typename add_value<A2>::type B2;
  824. typedef typename add_value<A3>::type B3;
  825. typedef typename add_value<A4>::type B4;
  826. typedef typename add_value<A5>::type B5;
  827. typedef typename add_value<A6>::type B6;
  828. typedef typename add_value<A7>::type B7;
  829. typedef list7<B1, B2, B3, B4, B5, B6, B7> type;
  830. };
  831. template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct list_av_8
  832. {
  833. typedef typename add_value<A1>::type B1;
  834. typedef typename add_value<A2>::type B2;
  835. typedef typename add_value<A3>::type B3;
  836. typedef typename add_value<A4>::type B4;
  837. typedef typename add_value<A5>::type B5;
  838. typedef typename add_value<A6>::type B6;
  839. typedef typename add_value<A7>::type B7;
  840. typedef typename add_value<A8>::type B8;
  841. typedef list8<B1, B2, B3, B4, B5, B6, B7, B8> type;
  842. };
  843. template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> struct list_av_9
  844. {
  845. typedef typename add_value<A1>::type B1;
  846. typedef typename add_value<A2>::type B2;
  847. typedef typename add_value<A3>::type B3;
  848. typedef typename add_value<A4>::type B4;
  849. typedef typename add_value<A5>::type B5;
  850. typedef typename add_value<A6>::type B6;
  851. typedef typename add_value<A7>::type B7;
  852. typedef typename add_value<A8>::type B8;
  853. typedef typename add_value<A9>::type B9;
  854. typedef list9<B1, B2, B3, B4, B5, B6, B7, B8, B9> type;
  855. };
  856. // operator!
  857. struct logical_not
  858. {
  859. template<class V> bool operator()(V const & v) const { return !v; }
  860. };
  861. template<class R, class F, class L>
  862. bind_t< bool, logical_not, list1< bind_t<R, F, L> > >
  863. operator! (bind_t<R, F, L> const & f)
  864. {
  865. typedef list1< bind_t<R, F, L> > list_type;
  866. return bind_t<bool, logical_not, list_type> ( logical_not(), list_type(f) );
  867. }
  868. // relational operators
  869. #define BOOST_BIND_OPERATOR( op, name ) \
  870. \
  871. struct name \
  872. { \
  873. template<class V, class W> bool operator()(V const & v, W const & w) const { return v op w; } \
  874. }; \
  875. \
  876. template<class R, class F, class L, class A2> \
  877. bind_t< bool, name, list2< bind_t<R, F, L>, typename add_value<A2>::type > > \
  878. operator op (bind_t<R, F, L> const & f, A2 a2) \
  879. { \
  880. typedef typename add_value<A2>::type B2; \
  881. typedef list2< bind_t<R, F, L>, B2> list_type; \
  882. return bind_t<bool, name, list_type> ( name(), list_type(f, a2) ); \
  883. }
  884. BOOST_BIND_OPERATOR( ==, equal )
  885. BOOST_BIND_OPERATOR( !=, not_equal )
  886. BOOST_BIND_OPERATOR( <, less )
  887. BOOST_BIND_OPERATOR( <=, less_equal )
  888. BOOST_BIND_OPERATOR( >, greater )
  889. BOOST_BIND_OPERATOR( >=, greater_equal )
  890. BOOST_BIND_OPERATOR( &&, logical_and )
  891. BOOST_BIND_OPERATOR( ||, logical_or )
  892. #undef BOOST_BIND_OPERATOR
  893. #if defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3)
  894. // resolve ambiguity with rel_ops
  895. #define BOOST_BIND_OPERATOR( op, name ) \
  896. \
  897. template<class R, class F, class L> \
  898. bind_t< bool, name, list2< bind_t<R, F, L>, bind_t<R, F, L> > > \
  899. operator op (bind_t<R, F, L> const & f, bind_t<R, F, L> const & g) \
  900. { \
  901. typedef list2< bind_t<R, F, L>, bind_t<R, F, L> > list_type; \
  902. return bind_t<bool, name, list_type> ( name(), list_type(f, g) ); \
  903. }
  904. BOOST_BIND_OPERATOR( !=, not_equal )
  905. BOOST_BIND_OPERATOR( <=, less_equal )
  906. BOOST_BIND_OPERATOR( >, greater )
  907. BOOST_BIND_OPERATOR( >=, greater_equal )
  908. #endif
  909. // visit_each, ADL
  910. #if !defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) && !defined( __BORLANDC__ ) \
  911. && !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
  912. template<class V, class T> void visit_each( V & v, value<T> const & t, int )
  913. {
  914. using boost::visit_each;
  915. BOOST_BIND_VISIT_EACH( v, t.get(), 0 );
  916. }
  917. template<class V, class R, class F, class L> void visit_each( V & v, bind_t<R, F, L> const & t, int )
  918. {
  919. t.accept( v );
  920. }
  921. #endif
  922. } // namespace _bi
  923. // visit_each, no ADL
  924. #if defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) || defined( __BORLANDC__ ) \
  925. || (defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
  926. template<class V, class T> void visit_each( V & v, _bi::value<T> const & t, int )
  927. {
  928. BOOST_BIND_VISIT_EACH( v, t.get(), 0 );
  929. }
  930. template<class V, class R, class F, class L> void visit_each( V & v, _bi::bind_t<R, F, L> const & t, int )
  931. {
  932. t.accept( v );
  933. }
  934. #endif
  935. // is_bind_expression
  936. template< class T > struct is_bind_expression
  937. {
  938. enum _vt { value = 0 };
  939. };
  940. #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
  941. template< class R, class F, class L > struct is_bind_expression< _bi::bind_t< R, F, L > >
  942. {
  943. enum _vt { value = 1 };
  944. };
  945. #endif
  946. // bind
  947. #ifndef BOOST_BIND
  948. #define BOOST_BIND bind
  949. #endif
  950. // generic function objects
  951. template<class R, class F>
  952. _bi::bind_t<R, F, _bi::list0>
  953. BOOST_BIND(F f)
  954. {
  955. typedef _bi::list0 list_type;
  956. return _bi::bind_t<R, F, list_type> (f, list_type());
  957. }
  958. template<class R, class F, class A1>
  959. _bi::bind_t<R, F, typename _bi::list_av_1<A1>::type>
  960. BOOST_BIND(F f, A1 a1)
  961. {
  962. typedef typename _bi::list_av_1<A1>::type list_type;
  963. return _bi::bind_t<R, F, list_type> (f, list_type(a1));
  964. }
  965. template<class R, class F, class A1, class A2>
  966. _bi::bind_t<R, F, typename _bi::list_av_2<A1, A2>::type>
  967. BOOST_BIND(F f, A1 a1, A2 a2)
  968. {
  969. typedef typename _bi::list_av_2<A1, A2>::type list_type;
  970. return _bi::bind_t<R, F, list_type> (f, list_type(a1, a2));
  971. }
  972. template<class R, class F, class A1, class A2, class A3>
  973. _bi::bind_t<R, F, typename _bi::list_av_3<A1, A2, A3>::type>
  974. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3)
  975. {
  976. typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
  977. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3));
  978. }
  979. template<class R, class F, class A1, class A2, class A3, class A4>
  980. _bi::bind_t<R, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
  981. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4)
  982. {
  983. typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
  984. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4));
  985. }
  986. template<class R, class F, class A1, class A2, class A3, class A4, class A5>
  987. _bi::bind_t<R, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
  988. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
  989. {
  990. typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
  991. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
  992. }
  993. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6>
  994. _bi::bind_t<R, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
  995. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
  996. {
  997. typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
  998. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
  999. }
  1000. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
  1001. _bi::bind_t<R, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
  1002. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
  1003. {
  1004. typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
  1005. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
  1006. }
  1007. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
  1008. _bi::bind_t<R, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
  1009. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
  1010. {
  1011. typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
  1012. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
  1013. }
  1014. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
  1015. _bi::bind_t<R, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
  1016. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
  1017. {
  1018. typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
  1019. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
  1020. }
  1021. // generic function objects, alternative syntax
  1022. template<class R, class F>
  1023. _bi::bind_t<R, F, _bi::list0>
  1024. BOOST_BIND(boost::type<R>, F f)
  1025. {
  1026. typedef _bi::list0 list_type;
  1027. return _bi::bind_t<R, F, list_type> (f, list_type());
  1028. }
  1029. template<class R, class F, class A1>
  1030. _bi::bind_t<R, F, typename _bi::list_av_1<A1>::type>
  1031. BOOST_BIND(boost::type<R>, F f, A1 a1)
  1032. {
  1033. typedef typename _bi::list_av_1<A1>::type list_type;
  1034. return _bi::bind_t<R, F, list_type> (f, list_type(a1));
  1035. }
  1036. template<class R, class F, class A1, class A2>
  1037. _bi::bind_t<R, F, typename _bi::list_av_2<A1, A2>::type>
  1038. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2)
  1039. {
  1040. typedef typename _bi::list_av_2<A1, A2>::type list_type;
  1041. return _bi::bind_t<R, F, list_type> (f, list_type(a1, a2));
  1042. }
  1043. template<class R, class F, class A1, class A2, class A3>
  1044. _bi::bind_t<R, F, typename _bi::list_av_3<A1, A2, A3>::type>
  1045. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3)
  1046. {
  1047. typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
  1048. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3));
  1049. }
  1050. template<class R, class F, class A1, class A2, class A3, class A4>
  1051. _bi::bind_t<R, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
  1052. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4)
  1053. {
  1054. typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
  1055. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4));
  1056. }
  1057. template<class R, class F, class A1, class A2, class A3, class A4, class A5>
  1058. _bi::bind_t<R, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
  1059. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
  1060. {
  1061. typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
  1062. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
  1063. }
  1064. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6>
  1065. _bi::bind_t<R, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
  1066. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
  1067. {
  1068. typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
  1069. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
  1070. }
  1071. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
  1072. _bi::bind_t<R, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
  1073. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
  1074. {
  1075. typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
  1076. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
  1077. }
  1078. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
  1079. _bi::bind_t<R, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
  1080. BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
  1081. {
  1082. typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
  1083. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
  1084. }
  1085. template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
  1086. _bi::bind_t<R, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
  1087. 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)
  1088. {
  1089. typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
  1090. return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
  1091. }
  1092. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
  1093. // adaptable function objects
  1094. template<class F>
  1095. _bi::bind_t<_bi::unspecified, F, _bi::list0>
  1096. BOOST_BIND(F f)
  1097. {
  1098. typedef _bi::list0 list_type;
  1099. return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type());
  1100. }
  1101. template<class F, class A1>
  1102. _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_1<A1>::type>
  1103. BOOST_BIND(F f, A1 a1)
  1104. {
  1105. typedef typename _bi::list_av_1<A1>::type list_type;
  1106. return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type(a1));
  1107. }
  1108. template<class F, class A1, class A2>
  1109. _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_2<A1, A2>::type>
  1110. BOOST_BIND(F f, A1 a1, A2 a2)
  1111. {
  1112. typedef typename _bi::list_av_2<A1, A2>::type list_type;
  1113. return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type(a1, a2));
  1114. }
  1115. template<class F, class A1, class A2, class A3>
  1116. _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_3<A1, A2, A3>::type>
  1117. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3)
  1118. {
  1119. typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
  1120. return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3));
  1121. }
  1122. template<class F, class A1, class A2, class A3, class A4>
  1123. _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
  1124. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4)
  1125. {
  1126. typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
  1127. return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4));
  1128. }
  1129. template<class F, class A1, class A2, class A3, class A4, class A5>
  1130. _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
  1131. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
  1132. {
  1133. typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
  1134. return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
  1135. }
  1136. template<class F, class A1, class A2, class A3, class A4, class A5, class A6>
  1137. _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
  1138. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
  1139. {
  1140. typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
  1141. return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
  1142. }
  1143. template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
  1144. _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
  1145. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
  1146. {
  1147. typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
  1148. return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
  1149. }
  1150. template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
  1151. _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
  1152. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
  1153. {
  1154. typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
  1155. return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
  1156. }
  1157. template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
  1158. _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
  1159. BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
  1160. {
  1161. typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
  1162. return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
  1163. }
  1164. #endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
  1165. // function pointers
  1166. #define BOOST_BIND_CC
  1167. #define BOOST_BIND_ST
  1168. #include <boost/bind/bind_cc.hpp>
  1169. #undef BOOST_BIND_CC
  1170. #undef BOOST_BIND_ST
  1171. #ifdef BOOST_BIND_ENABLE_STDCALL
  1172. #define BOOST_BIND_CC __stdcall
  1173. #define BOOST_BIND_ST
  1174. #include <boost/bind/bind_cc.hpp>
  1175. #undef BOOST_BIND_CC
  1176. #undef BOOST_BIND_ST
  1177. #endif
  1178. #ifdef BOOST_BIND_ENABLE_FASTCALL
  1179. #define BOOST_BIND_CC __fastcall
  1180. #define BOOST_BIND_ST
  1181. #include <boost/bind/bind_cc.hpp>
  1182. #undef BOOST_BIND_CC
  1183. #undef BOOST_BIND_ST
  1184. #endif
  1185. #ifdef BOOST_BIND_ENABLE_PASCAL
  1186. #define BOOST_BIND_ST pascal
  1187. #define BOOST_BIND_CC
  1188. #include <boost/bind/bind_cc.hpp>
  1189. #undef BOOST_BIND_ST
  1190. #undef BOOST_BIND_CC
  1191. #endif
  1192. // member function pointers
  1193. #define BOOST_BIND_MF_NAME(X) X
  1194. #define BOOST_BIND_MF_CC
  1195. #include <boost/bind/bind_mf_cc.hpp>
  1196. #include <boost/bind/bind_mf2_cc.hpp>
  1197. #undef BOOST_BIND_MF_NAME
  1198. #undef BOOST_BIND_MF_CC
  1199. #ifdef BOOST_MEM_FN_ENABLE_CDECL
  1200. #define BOOST_BIND_MF_NAME(X) X##_cdecl
  1201. #define BOOST_BIND_MF_CC __cdecl
  1202. #include <boost/bind/bind_mf_cc.hpp>
  1203. #include <boost/bind/bind_mf2_cc.hpp>
  1204. #undef BOOST_BIND_MF_NAME
  1205. #undef BOOST_BIND_MF_CC
  1206. #endif
  1207. #ifdef BOOST_MEM_FN_ENABLE_STDCALL
  1208. #define BOOST_BIND_MF_NAME(X) X##_stdcall
  1209. #define BOOST_BIND_MF_CC __stdcall
  1210. #include <boost/bind/bind_mf_cc.hpp>
  1211. #include <boost/bind/bind_mf2_cc.hpp>
  1212. #undef BOOST_BIND_MF_NAME
  1213. #undef BOOST_BIND_MF_CC
  1214. #endif
  1215. #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
  1216. #define BOOST_BIND_MF_NAME(X) X##_fastcall
  1217. #define BOOST_BIND_MF_CC __fastcall
  1218. #include <boost/bind/bind_mf_cc.hpp>
  1219. #include <boost/bind/bind_mf2_cc.hpp>
  1220. #undef BOOST_BIND_MF_NAME
  1221. #undef BOOST_BIND_MF_CC
  1222. #endif
  1223. // data member pointers
  1224. #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
  1225. || ( defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, <= 0x610 ) )
  1226. template<class R, class T, class A1>
  1227. _bi::bind_t< R, _mfi::dm<R, T>, typename _bi::list_av_1<A1>::type >
  1228. BOOST_BIND(R T::*f, A1 a1)
  1229. {
  1230. typedef _mfi::dm<R, T> F;
  1231. typedef typename _bi::list_av_1<A1>::type list_type;
  1232. return _bi::bind_t<R, F, list_type>( F(f), list_type(a1) );
  1233. }
  1234. #else
  1235. namespace _bi
  1236. {
  1237. template< class Pm, int I > struct add_cref;
  1238. template< class M, class T > struct add_cref< M T::*, 0 >
  1239. {
  1240. typedef M type;
  1241. };
  1242. template< class M, class T > struct add_cref< M T::*, 1 >
  1243. {
  1244. typedef M const & type;
  1245. };
  1246. template< class R, class T > struct add_cref< R (T::*) (), 1 >
  1247. {
  1248. typedef void type;
  1249. };
  1250. #if !( defined(__IBMCPP__) && BOOST_WORKAROUND( __IBMCPP__, BOOST_TESTED_AT(600) ) )
  1251. template< class R, class T > struct add_cref< R (T::*) () const, 1 >
  1252. {
  1253. typedef void type;
  1254. };
  1255. #endif // __IBMCPP__
  1256. template<class R> struct isref
  1257. {
  1258. enum value_type { value = 0 };
  1259. };
  1260. template<class R> struct isref< R& >
  1261. {
  1262. enum value_type { value = 1 };
  1263. };
  1264. template<class R> struct isref< R* >
  1265. {
  1266. enum value_type { value = 1 };
  1267. };
  1268. template<class Pm, class A1> struct dm_result
  1269. {
  1270. typedef typename add_cref< Pm, 1 >::type type;
  1271. };
  1272. template<class Pm, class R, class F, class L> struct dm_result< Pm, bind_t<R, F, L> >
  1273. {
  1274. typedef typename bind_t<R, F, L>::result_type result_type;
  1275. typedef typename add_cref< Pm, isref< result_type >::value >::type type;
  1276. };
  1277. } // namespace _bi
  1278. template< class A1, class M, class T >
  1279. _bi::bind_t<
  1280. typename _bi::dm_result< M T::*, A1 >::type,
  1281. _mfi::dm<M, T>,
  1282. typename _bi::list_av_1<A1>::type
  1283. >
  1284. BOOST_BIND( M T::*f, A1 a1 )
  1285. {
  1286. typedef typename _bi::dm_result< M T::*, A1 >::type result_type;
  1287. typedef _mfi::dm<M, T> F;
  1288. typedef typename _bi::list_av_1<A1>::type list_type;
  1289. return _bi::bind_t< result_type, F, list_type >( F( f ), list_type( a1 ) );
  1290. }
  1291. #endif
  1292. } // namespace boost
  1293. #ifndef BOOST_BIND_NO_PLACEHOLDERS
  1294. # include <boost/bind/placeholders.hpp>
  1295. #endif
  1296. #ifdef BOOST_MSVC
  1297. # pragma warning(default: 4512) // assignment operator could not be generated
  1298. # pragma warning(pop)
  1299. #endif
  1300. #endif // #ifndef BOOST_BIND_BIND_HPP_INCLUDED