1 #ifndef BOOST_BIND_HPP_INCLUDED
2 #define BOOST_BIND_HPP_INCLUDED
9 // bind.hpp - binds function objects to arguments
11 // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
12 // Copyright (c) 2001 David Abrahams
14 // Permission to copy, use, modify, sell and distribute this software
15 // is granted provided this copyright notice appears in all copies.
16 // This software is provided "as is" without express or implied
17 // warranty, and with no claim as to its suitability for any purpose.
19 // See http://www.boost.org/libs/bind/bind.html for documentation.
22 #include <boost/config.hpp>
23 #include <boost/ref.hpp>
24 #include <boost/mem_fn.hpp>
25 #include <boost/bind/arg.hpp>
27 // Borland-specific bug, visit_each() silently fails to produce code
29 #if defined(__BORLANDC__)
30 # define BOOST_BIND_VISIT_EACH boost::visit_each
32 # define BOOST_BIND_VISIT_EACH visit_each
36 # pragma warning(push)
37 # pragma warning(disable: 4512) // assignment operator could not be generated
43 namespace _bi // implementation details
48 template<class R, class F> struct result_traits
53 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
55 struct unspecified {};
57 template<class F> struct result_traits<unspecified, F>
59 typedef typename F::result_type type;
62 template<class F> struct result_traits< unspecified, reference_wrapper<F> >
64 typedef typename F::result_type type;
69 // bind_t forward declaration for listN
71 template<class R, class F, class L> class bind_t;
75 template<class T> class value
79 value(T const & t): t_(t) {}
81 T & get() { return t_; }
82 T const & get() const { return t_; }
91 template<class T> class type {};
95 template<class F> inline F & unwrap(F & f, long)
100 template<class F> inline F & unwrap(reference_wrapper<F> & f, int)
105 template<class F> inline F & unwrap(reference_wrapper<F> const & f, int)
112 #ifdef BOOST_NO_VOID_RETURNS
114 template <class R> struct evaluator0;
115 template <class R> struct evaluator1;
116 template <class R> struct evaluator2;
117 template <class R> struct evaluator3;
118 template <class R> struct evaluator4;
119 template <class R> struct evaluator5;
120 template <class R> struct evaluator6;
121 template <class R> struct evaluator7;
122 template <class R> struct evaluator8;
123 template <class R> struct evaluator9;
133 template<class T> T & operator[] (value<T> & v) const { return v.get(); }
135 template<class T> T const & operator[] (value<T> const & v) const { return v.get(); }
137 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
139 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); }
141 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); }
143 template<class R, class F, class A> R operator()(type<R>, F f, A &) const
145 return unwrap(f, 0)();
148 template<class V> void accept(V &) const
152 #ifdef BOOST_NO_VOID_RETURNS
154 template<class R> struct evaluator
156 typedef evaluator0<R> type;
163 template<class A1> class list1
167 explicit list1(A1 a1): a1_(a1) {}
169 A1 operator[] (arg<1>) const { return a1_; }
171 A1 operator[] (arg<1> (*) ()) const { return a1_; }
173 template<class T> T & operator[] (value<T> & v) const { return v.get(); }
175 template<class T> T const & operator[] (value<T> const & v) const { return v.get(); }
177 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
179 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); }
181 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); }
183 template<class R, class F, class A> R operator()(type<R>, F f, A & a) const
185 return unwrap(f, 0)(a[a1_]);
188 template<class V> void accept(V & v) const
190 BOOST_BIND_VISIT_EACH(v, a1_, 0);
193 #ifdef BOOST_NO_VOID_RETURNS
195 template<class R> struct evaluator
197 typedef evaluator1<R> type;
209 template<class A1, class A2> class list2
213 list2(A1 a1, A2 a2): a1_(a1), a2_(a2) {}
215 A1 operator[] (arg<1>) const { return a1_; }
216 A2 operator[] (arg<2>) const { return a2_; }
218 A1 operator[] (arg<1> (*) ()) const { return a1_; }
219 A2 operator[] (arg<2> (*) ()) const { return a2_; }
221 template<class T> T & operator[] (value<T> & v) const { return v.get(); }
223 template<class T> T const & operator[] (value<T> const & v) const { return v.get(); }
225 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
227 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); }
229 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); }
231 template<class R, class F, class A> R operator()(type<R>, F f, A & a) const
233 return unwrap(f, 0)(a[a1_], a[a2_]);
236 template<class V> void accept(V & v) const
238 BOOST_BIND_VISIT_EACH(v, a1_, 0);
239 BOOST_BIND_VISIT_EACH(v, a2_, 0);
242 #ifdef BOOST_NO_VOID_RETURNS
244 template<class R> struct evaluator
246 typedef evaluator2<R> type;
259 template<class A1, class A2, class A3> class list3
263 list3(A1 a1, A2 a2, A3 a3): a1_(a1), a2_(a2), a3_(a3) {}
265 A1 operator[] (arg<1>) const { return a1_; }
266 A2 operator[] (arg<2>) const { return a2_; }
267 A3 operator[] (arg<3>) const { return a3_; }
269 A1 operator[] (arg<1> (*) ()) const { return a1_; }
270 A2 operator[] (arg<2> (*) ()) const { return a2_; }
271 A3 operator[] (arg<3> (*) ()) const { return a3_; }
273 template<class T> T & operator[] (value<T> & v) const { return v.get(); }
275 template<class T> T const & operator[] (value<T> const & v) const { return v.get(); }
277 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
279 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); }
281 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); }
283 template<class R, class F, class A> R operator()(type<R>, F f, A & a) const
285 return unwrap(f, 0)(a[a1_], a[a2_], a[a3_]);
288 template<class V> void accept(V & v) const
290 BOOST_BIND_VISIT_EACH(v, a1_, 0);
291 BOOST_BIND_VISIT_EACH(v, a2_, 0);
292 BOOST_BIND_VISIT_EACH(v, a3_, 0);
295 #ifdef BOOST_NO_VOID_RETURNS
297 template<class R> struct evaluator
299 typedef evaluator3<R> type;
313 template<class A1, class A2, class A3, class A4> class list4
317 list4(A1 a1, A2 a2, A3 a3, A4 a4): a1_(a1), a2_(a2), a3_(a3), a4_(a4) {}
319 A1 operator[] (arg<1>) const { return a1_; }
320 A2 operator[] (arg<2>) const { return a2_; }
321 A3 operator[] (arg<3>) const { return a3_; }
322 A4 operator[] (arg<4>) const { return a4_; }
324 A1 operator[] (arg<1> (*) ()) const { return a1_; }
325 A2 operator[] (arg<2> (*) ()) const { return a2_; }
326 A3 operator[] (arg<3> (*) ()) const { return a3_; }
327 A4 operator[] (arg<4> (*) ()) const { return a4_; }
329 template<class T> T & operator[] (value<T> & v) const { return v.get(); }
331 template<class T> T const & operator[] (value<T> const & v) const { return v.get(); }
333 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
335 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); }
337 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); }
339 template<class R, class F, class A> R operator()(type<R>, F f, A & a) const
341 return unwrap(f, 0)(a[a1_], a[a2_], a[a3_], a[a4_]);
344 template<class V> void accept(V & v) const
346 BOOST_BIND_VISIT_EACH(v, a1_, 0);
347 BOOST_BIND_VISIT_EACH(v, a2_, 0);
348 BOOST_BIND_VISIT_EACH(v, a3_, 0);
349 BOOST_BIND_VISIT_EACH(v, a4_, 0);
352 #ifdef BOOST_NO_VOID_RETURNS
354 template<class R> struct evaluator
356 typedef evaluator4<R> type;
371 template<class A1, class A2, class A3, class A4, class A5> class list5
375 list5(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5): a1_(a1), a2_(a2), a3_(a3), a4_(a4), a5_(a5) {}
377 A1 operator[] (arg<1>) const { return a1_; }
378 A2 operator[] (arg<2>) const { return a2_; }
379 A3 operator[] (arg<3>) const { return a3_; }
380 A4 operator[] (arg<4>) const { return a4_; }
381 A5 operator[] (arg<5>) const { return a5_; }
383 A1 operator[] (arg<1> (*) ()) const { return a1_; }
384 A2 operator[] (arg<2> (*) ()) const { return a2_; }
385 A3 operator[] (arg<3> (*) ()) const { return a3_; }
386 A4 operator[] (arg<4> (*) ()) const { return a4_; }
387 A5 operator[] (arg<5> (*) ()) const { return a5_; }
389 template<class T> T & operator[] (value<T> & v) const { return v.get(); }
391 template<class T> T const & operator[] (value<T> const & v) const { return v.get(); }
393 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
395 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); }
397 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); }
399 template<class R, class F, class A> R operator()(type<R>, F f, A & a) const
401 return unwrap(f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_]);
404 template<class V> void accept(V & v) const
406 BOOST_BIND_VISIT_EACH(v, a1_, 0);
407 BOOST_BIND_VISIT_EACH(v, a2_, 0);
408 BOOST_BIND_VISIT_EACH(v, a3_, 0);
409 BOOST_BIND_VISIT_EACH(v, a4_, 0);
410 BOOST_BIND_VISIT_EACH(v, a5_, 0);
413 #ifdef BOOST_NO_VOID_RETURNS
415 template<class R> struct evaluator
417 typedef evaluator5<R> type;
433 template<class A1, class A2, class A3, class A4, class A5, class A6> class list6
437 list6(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6): a1_(a1), a2_(a2), a3_(a3), a4_(a4), a5_(a5), a6_(a6) {}
439 A1 operator[] (arg<1>) const { return a1_; }
440 A2 operator[] (arg<2>) const { return a2_; }
441 A3 operator[] (arg<3>) const { return a3_; }
442 A4 operator[] (arg<4>) const { return a4_; }
443 A5 operator[] (arg<5>) const { return a5_; }
444 A6 operator[] (arg<6>) const { return a6_; }
446 A1 operator[] (arg<1> (*) ()) const { return a1_; }
447 A2 operator[] (arg<2> (*) ()) const { return a2_; }
448 A3 operator[] (arg<3> (*) ()) const { return a3_; }
449 A4 operator[] (arg<4> (*) ()) const { return a4_; }
450 A5 operator[] (arg<5> (*) ()) const { return a5_; }
451 A6 operator[] (arg<6> (*) ()) const { return a6_; }
453 template<class T> T & operator[] (value<T> & v) const { return v.get(); }
455 template<class T> T const & operator[] (value<T> const & v) const { return v.get(); }
457 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
459 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); }
461 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); }
463 template<class R, class F, class A> R operator()(type<R>, F f, A & a) const
465 return unwrap(f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_]);
468 template<class V> void accept(V & v) const
470 BOOST_BIND_VISIT_EACH(v, a1_, 0);
471 BOOST_BIND_VISIT_EACH(v, a2_, 0);
472 BOOST_BIND_VISIT_EACH(v, a3_, 0);
473 BOOST_BIND_VISIT_EACH(v, a4_, 0);
474 BOOST_BIND_VISIT_EACH(v, a5_, 0);
475 BOOST_BIND_VISIT_EACH(v, a6_, 0);
478 #ifdef BOOST_NO_VOID_RETURNS
480 template<class R> struct evaluator
482 typedef evaluator6<R> type;
499 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> class list7
503 list7(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7): a1_(a1), a2_(a2), a3_(a3), a4_(a4), a5_(a5), a6_(a6), a7_(a7) {}
505 A1 operator[] (arg<1>) const { return a1_; }
506 A2 operator[] (arg<2>) const { return a2_; }
507 A3 operator[] (arg<3>) const { return a3_; }
508 A4 operator[] (arg<4>) const { return a4_; }
509 A5 operator[] (arg<5>) const { return a5_; }
510 A6 operator[] (arg<6>) const { return a6_; }
511 A7 operator[] (arg<7>) const { return a7_; }
513 A1 operator[] (arg<1> (*) ()) const { return a1_; }
514 A2 operator[] (arg<2> (*) ()) const { return a2_; }
515 A3 operator[] (arg<3> (*) ()) const { return a3_; }
516 A4 operator[] (arg<4> (*) ()) const { return a4_; }
517 A5 operator[] (arg<5> (*) ()) const { return a5_; }
518 A6 operator[] (arg<6> (*) ()) const { return a6_; }
519 A7 operator[] (arg<7> (*) ()) const { return a7_; }
521 template<class T> T & operator[] (value<T> & v) const { return v.get(); }
523 template<class T> T const & operator[] (value<T> const & v) const { return v.get(); }
525 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
527 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); }
529 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); }
531 template<class R, class F, class A> R operator()(type<R>, F f, A & a) const
533 return unwrap(f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_]);
536 template<class V> void accept(V & v) const
538 BOOST_BIND_VISIT_EACH(v, a1_, 0);
539 BOOST_BIND_VISIT_EACH(v, a2_, 0);
540 BOOST_BIND_VISIT_EACH(v, a3_, 0);
541 BOOST_BIND_VISIT_EACH(v, a4_, 0);
542 BOOST_BIND_VISIT_EACH(v, a5_, 0);
543 BOOST_BIND_VISIT_EACH(v, a6_, 0);
544 BOOST_BIND_VISIT_EACH(v, a7_, 0);
547 #ifdef BOOST_NO_VOID_RETURNS
549 template<class R> struct evaluator
551 typedef evaluator7<R> type;
569 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> class list8
573 list8(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8): a1_(a1), a2_(a2), a3_(a3), a4_(a4), a5_(a5), a6_(a6), a7_(a7), a8_(a8) {}
575 A1 operator[] (arg<1>) const { return a1_; }
576 A2 operator[] (arg<2>) const { return a2_; }
577 A3 operator[] (arg<3>) const { return a3_; }
578 A4 operator[] (arg<4>) const { return a4_; }
579 A5 operator[] (arg<5>) const { return a5_; }
580 A6 operator[] (arg<6>) const { return a6_; }
581 A7 operator[] (arg<7>) const { return a7_; }
582 A8 operator[] (arg<8>) const { return a8_; }
584 A1 operator[] (arg<1> (*) ()) const { return a1_; }
585 A2 operator[] (arg<2> (*) ()) const { return a2_; }
586 A3 operator[] (arg<3> (*) ()) const { return a3_; }
587 A4 operator[] (arg<4> (*) ()) const { return a4_; }
588 A5 operator[] (arg<5> (*) ()) const { return a5_; }
589 A6 operator[] (arg<6> (*) ()) const { return a6_; }
590 A7 operator[] (arg<7> (*) ()) const { return a7_; }
591 A8 operator[] (arg<8> (*) ()) const { return a8_; }
593 template<class T> T & operator[] (value<T> & v) const { return v.get(); }
595 template<class T> T const & operator[] (value<T> const & v) const { return v.get(); }
597 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
599 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); }
601 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); }
603 template<class R, class F, class A> R operator()(type<R>, F f, A & a) const
605 return unwrap(f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_], a[a8_]);
608 template<class V> void accept(V & v) const
610 BOOST_BIND_VISIT_EACH(v, a1_, 0);
611 BOOST_BIND_VISIT_EACH(v, a2_, 0);
612 BOOST_BIND_VISIT_EACH(v, a3_, 0);
613 BOOST_BIND_VISIT_EACH(v, a4_, 0);
614 BOOST_BIND_VISIT_EACH(v, a5_, 0);
615 BOOST_BIND_VISIT_EACH(v, a6_, 0);
616 BOOST_BIND_VISIT_EACH(v, a7_, 0);
617 BOOST_BIND_VISIT_EACH(v, a8_, 0);
620 #ifdef BOOST_NO_VOID_RETURNS
622 template<class R> struct evaluator
624 typedef evaluator8<R> type;
643 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> class list9
647 list9(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9): a1_(a1), a2_(a2), a3_(a3), a4_(a4), a5_(a5), a6_(a6), a7_(a7), a8_(a8), a9_(a9) {}
649 A1 operator[] (arg<1>) const { return a1_; }
650 A2 operator[] (arg<2>) const { return a2_; }
651 A3 operator[] (arg<3>) const { return a3_; }
652 A4 operator[] (arg<4>) const { return a4_; }
653 A5 operator[] (arg<5>) const { return a5_; }
654 A6 operator[] (arg<6>) const { return a6_; }
655 A7 operator[] (arg<7>) const { return a7_; }
656 A8 operator[] (arg<8>) const { return a8_; }
657 A9 operator[] (arg<9>) const { return a9_; }
659 A1 operator[] (arg<1> (*) ()) const { return a1_; }
660 A2 operator[] (arg<2> (*) ()) const { return a2_; }
661 A3 operator[] (arg<3> (*) ()) const { return a3_; }
662 A4 operator[] (arg<4> (*) ()) const { return a4_; }
663 A5 operator[] (arg<5> (*) ()) const { return a5_; }
664 A6 operator[] (arg<6> (*) ()) const { return a6_; }
665 A7 operator[] (arg<7> (*) ()) const { return a7_; }
666 A8 operator[] (arg<8> (*) ()) const { return a8_; }
667 A9 operator[] (arg<9> (*) ()) const { return a9_; }
669 template<class T> T & operator[] (value<T> & v) const { return v.get(); }
671 template<class T> T const & operator[] (value<T> const & v) const { return v.get(); }
673 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
675 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); }
677 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); }
679 template<class R, class F, class A> R operator()(type<R>, F f, A & a) const
681 return unwrap(f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_], a[a8_], a[a9_]);
684 template<class V> void accept(V & v) const
686 BOOST_BIND_VISIT_EACH(v, a1_, 0);
687 BOOST_BIND_VISIT_EACH(v, a2_, 0);
688 BOOST_BIND_VISIT_EACH(v, a3_, 0);
689 BOOST_BIND_VISIT_EACH(v, a4_, 0);
690 BOOST_BIND_VISIT_EACH(v, a5_, 0);
691 BOOST_BIND_VISIT_EACH(v, a6_, 0);
692 BOOST_BIND_VISIT_EACH(v, a7_, 0);
693 BOOST_BIND_VISIT_EACH(v, a8_, 0);
694 BOOST_BIND_VISIT_EACH(v, a9_, 0);
697 #ifdef BOOST_NO_VOID_RETURNS
699 template<class R> struct evaluator
701 typedef evaluator9<R> type;
721 #ifdef BOOST_NO_VOID_RETURNS
723 template <class R> struct evaluator0
725 template<class L, class F, class A>
726 static R eval(L const&, F f, A &)
728 return unwrap(f, 0)();
732 template <> struct evaluator0<void>
734 template<class L, class F, class A>
735 static void eval(L const&, F f, A &)
741 template <class R> struct evaluator1
743 template<class L, class F, class A>
744 static R eval(L const& l, F f, A & a)
746 return unwrap(f, 0)(a[l.a1_]);
750 template <> struct evaluator1<void>
752 template<class L, class F, class A>
753 static void eval(L const& l, F f, A & a)
755 unwrap(f, 0)(a[l.a1_]);
759 template <class R> struct evaluator2
761 template<class L, class F, class A>
762 static R eval(L const& l, F f, A & a)
764 return unwrap(f, 0)(a[l.a1_], a[l.a2_]);
768 template <> struct evaluator2<void>
770 template<class L, class F, class A>
771 static void eval(L const& l, F f, A & a)
773 unwrap(f, 0)(a[l.a1_], a[l.a2_]);
777 template <class R> struct evaluator3
779 template<class L, class F, class A>
780 static R eval(L const& l, F f, A & a)
782 return unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_]);
786 template <> struct evaluator3<void>
788 template<class L, class F, class A>
789 static void eval(L const& l, F f, A & a)
791 unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_]);
795 template <class R> struct evaluator4
797 template<class L, class F, class A>
798 static R eval(L const& l, F f, A & a)
800 return unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_], a[l.a4_]);
804 template <> struct evaluator4<void>
806 template<class L, class F, class A>
807 static void eval(L const& l, F f, A & a)
809 unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_], a[l.a4_]);
813 template <class R> struct evaluator5
815 template<class L, class F, class A>
816 static R eval(L const& l, F f, A & a)
818 return unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_], a[l.a4_], a[l.a5_]);
822 template <> struct evaluator5<void>
824 template<class L, class F, class A>
825 static void eval(L const& l, F f, A & a)
827 unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_], a[l.a4_], a[l.a5_]);
831 template <class R> struct evaluator6
833 template<class L, class F, class A>
834 static R eval(L const& l, F f, A & a)
836 return unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_], a[l.a4_], a[l.a5_], a[l.a6_]);
840 template <> struct evaluator6<void>
842 template<class L, class F, class A>
843 static void eval(L const& l, F f, A & a)
845 unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_], a[l.a4_], a[l.a5_], a[l.a6_]);
849 template <class R> struct evaluator7
851 template<class L, class F, class A>
852 static R eval(L const& l, F f, A & a)
854 return unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_], a[l.a4_], a[l.a5_], a[l.a6_], a[l.a7_]);
858 template <> struct evaluator7<void>
860 template<class L, class F, class A>
861 static void eval(L const& l, F f, A & a)
863 unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_], a[l.a4_], a[l.a5_], a[l.a6_], a[l.a7_]);
867 template <class R> struct evaluator8
869 template<class L, class F, class A>
870 static R eval(L const& l, F f, A & a)
872 return unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_], a[l.a4_], a[l.a5_], a[l.a6_], a[l.a7_], a[l.a8_]);
876 template <> struct evaluator8<void>
878 template<class L, class F, class A>
879 static void eval(L const& l, F f, A & a)
881 unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_], a[l.a4_], a[l.a5_], a[l.a6_], a[l.a7_], a[l.a8_]);
885 template <class R> struct evaluator9
887 template<class L, class F, class A>
888 static R eval(L const& l, F f, A & a)
890 return unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_], a[l.a4_], a[l.a5_], a[l.a6_], a[l.a7_], a[l.a8_], a[l.a9_]);
894 template <> struct evaluator9<void>
896 template<class L, class F, class A>
897 static void eval(L const& l, F f, A & a)
899 unwrap(f, 0)(a[l.a1_], a[l.a2_], a[l.a3_], a[l.a4_], a[l.a5_], a[l.a6_], a[l.a7_], a[l.a8_], a[l.a9_]);
907 #ifndef BOOST_NO_VOID_RETURNS
909 template<class R, class F, class L> class bind_t
913 bind_t(F f, L const & l): f_(f), l_(l) {}
915 #define BOOST_BIND_EVALUATE return l_(type<result_type>(), f_, a)
916 #include <boost/bind/bind_template.hpp>
917 #undef BOOST_BIND_EVALUATE
923 template<class R> struct bind_t_generator
926 template<class F, class L> class implementation
930 implementation(F f, L const & l): f_(f), l_(l) {}
932 #define BOOST_BIND_EVALUATE return L::BOOST_NESTED_TEMPLATE evaluator<result_type>::type::eval(l_, f_, a);
933 #include <boost/bind/bind_template.hpp>
934 #undef BOOST_BIND_EVALUATE
940 template<> struct bind_t_generator<void>
943 template<class F, class L> class implementation
951 implementation(F f, L const & l): f_(f), l_(l) {}
953 #define BOOST_BIND_EVALUATE L::BOOST_NESTED_TEMPLATE evaluator<result_type>::type::eval(l_, f_, a);
954 #include <boost/bind/bind_template.hpp>
955 #undef BOOST_BIND_EVALUATE
961 template<class R2, class F, class L> class bind_t: public bind_t_generator<R2>::BOOST_NESTED_TEMPLATE implementation<F, L>
965 bind_t(F f, L const & l): bind_t_generator<R2>::BOOST_NESTED_TEMPLATE implementation<F, L>(f, l) {}
973 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530)
975 template<class T> struct add_value
977 typedef value<T> type;
980 template<class T> struct add_value< value<T> >
982 typedef value<T> type;
985 template<class T> struct add_value< reference_wrapper<T> >
987 typedef reference_wrapper<T> type;
990 template<int I> struct add_value< arg<I> >
995 template<int I> struct add_value< arg<I> (*) () >
997 typedef arg<I> (*type) ();
1000 template<class R, class F, class L> struct add_value< bind_t<R, F, L> >
1002 typedef bind_t<R, F, L> type;
1007 template<int I> struct _avt_0;
1009 template<> struct _avt_0<1>
1011 template<class T> struct inner
1017 template<> struct _avt_0<2>
1019 template<class T> struct inner
1021 typedef value<T> type;
1025 typedef char (&_avt_r1) [1];
1026 typedef char (&_avt_r2) [2];
1028 template<class T> _avt_r1 _avt_f(value<T>);
1029 template<class T> _avt_r1 _avt_f(reference_wrapper<T>);
1030 template<int I> _avt_r1 _avt_f(arg<I>);
1031 template<int I> _avt_r1 _avt_f(arg<I> (*) ());
1032 template<class R, class F, class L> _avt_r1 _avt_f(bind_t<R, F, L>);
1034 _avt_r2 _avt_f(...);
1036 template<class T> struct add_value
1039 typedef typename _avt_0<sizeof(_avt_f(t()))>::template inner<T>::type type;
1046 template<class A1> struct list_av_1
1048 typedef typename add_value<A1>::type B1;
1049 typedef list1<B1> type;
1052 template<class A1, class A2> struct list_av_2
1054 typedef typename add_value<A1>::type B1;
1055 typedef typename add_value<A2>::type B2;
1056 typedef list2<B1, B2> type;
1059 template<class A1, class A2, class A3> struct list_av_3
1061 typedef typename add_value<A1>::type B1;
1062 typedef typename add_value<A2>::type B2;
1063 typedef typename add_value<A3>::type B3;
1064 typedef list3<B1, B2, B3> type;
1067 template<class A1, class A2, class A3, class A4> struct list_av_4
1069 typedef typename add_value<A1>::type B1;
1070 typedef typename add_value<A2>::type B2;
1071 typedef typename add_value<A3>::type B3;
1072 typedef typename add_value<A4>::type B4;
1073 typedef list4<B1, B2, B3, B4> type;
1076 template<class A1, class A2, class A3, class A4, class A5> struct list_av_5
1078 typedef typename add_value<A1>::type B1;
1079 typedef typename add_value<A2>::type B2;
1080 typedef typename add_value<A3>::type B3;
1081 typedef typename add_value<A4>::type B4;
1082 typedef typename add_value<A5>::type B5;
1083 typedef list5<B1, B2, B3, B4, B5> type;
1086 template<class A1, class A2, class A3, class A4, class A5, class A6> struct list_av_6
1088 typedef typename add_value<A1>::type B1;
1089 typedef typename add_value<A2>::type B2;
1090 typedef typename add_value<A3>::type B3;
1091 typedef typename add_value<A4>::type B4;
1092 typedef typename add_value<A5>::type B5;
1093 typedef typename add_value<A6>::type B6;
1094 typedef list6<B1, B2, B3, B4, B5, B6> type;
1097 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct list_av_7
1099 typedef typename add_value<A1>::type B1;
1100 typedef typename add_value<A2>::type B2;
1101 typedef typename add_value<A3>::type B3;
1102 typedef typename add_value<A4>::type B4;
1103 typedef typename add_value<A5>::type B5;
1104 typedef typename add_value<A6>::type B6;
1105 typedef typename add_value<A7>::type B7;
1106 typedef list7<B1, B2, B3, B4, B5, B6, B7> type;
1109 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct list_av_8
1111 typedef typename add_value<A1>::type B1;
1112 typedef typename add_value<A2>::type B2;
1113 typedef typename add_value<A3>::type B3;
1114 typedef typename add_value<A4>::type B4;
1115 typedef typename add_value<A5>::type B5;
1116 typedef typename add_value<A6>::type B6;
1117 typedef typename add_value<A7>::type B7;
1118 typedef typename add_value<A8>::type B8;
1119 typedef list8<B1, B2, B3, B4, B5, B6, B7, B8> type;
1122 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> struct list_av_9
1124 typedef typename add_value<A1>::type B1;
1125 typedef typename add_value<A2>::type B2;
1126 typedef typename add_value<A3>::type B3;
1127 typedef typename add_value<A4>::type B4;
1128 typedef typename add_value<A5>::type B5;
1129 typedef typename add_value<A6>::type B6;
1130 typedef typename add_value<A7>::type B7;
1131 typedef typename add_value<A8>::type B8;
1132 typedef typename add_value<A9>::type B9;
1133 typedef list9<B1, B2, B3, B4, B5, B6, B7, B8, B9> type;
1140 template<class V, class T> void visit_each(V & v, _bi::value<T> const & t, int)
1142 BOOST_BIND_VISIT_EACH(v, t.get(), 0);
1145 template<class V, class R, class F, class L> void visit_each(V & v, _bi::bind_t<R, F, L> const & t, int)
1153 #define BOOST_BIND bind
1156 // generic function objects
1158 template<class R, class F>
1159 _bi::bind_t<R, F, _bi::list0>
1162 typedef _bi::list0 list_type;
1163 return _bi::bind_t<R, F, list_type> (f, list_type());
1166 template<class R, class F, class A1>
1167 _bi::bind_t<R, F, typename _bi::list_av_1<A1>::type>
1168 BOOST_BIND(F f, A1 a1)
1170 typedef typename _bi::list_av_1<A1>::type list_type;
1171 return _bi::bind_t<R, F, list_type> (f, list_type(a1));
1174 template<class R, class F, class A1, class A2>
1175 _bi::bind_t<R, F, typename _bi::list_av_2<A1, A2>::type>
1176 BOOST_BIND(F f, A1 a1, A2 a2)
1178 typedef typename _bi::list_av_2<A1, A2>::type list_type;
1179 return _bi::bind_t<R, F, list_type> (f, list_type(a1, a2));
1182 template<class R, class F, class A1, class A2, class A3>
1183 _bi::bind_t<R, F, typename _bi::list_av_3<A1, A2, A3>::type>
1184 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3)
1186 typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
1187 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3));
1190 template<class R, class F, class A1, class A2, class A3, class A4>
1191 _bi::bind_t<R, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
1192 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4)
1194 typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
1195 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4));
1198 template<class R, class F, class A1, class A2, class A3, class A4, class A5>
1199 _bi::bind_t<R, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
1200 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
1202 typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
1203 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
1206 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6>
1207 _bi::bind_t<R, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
1208 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
1210 typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
1211 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
1214 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
1215 _bi::bind_t<R, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
1216 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
1218 typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
1219 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
1222 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
1223 _bi::bind_t<R, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
1224 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
1226 typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
1227 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
1230 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
1231 _bi::bind_t<R, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
1232 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
1234 typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
1235 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
1238 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
1240 // adaptable function objects
1243 _bi::bind_t<_bi::unspecified, F, _bi::list0>
1246 typedef _bi::list0 list_type;
1247 return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type());
1250 template<class F, class A1>
1251 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_1<A1>::type>
1252 BOOST_BIND(F f, A1 a1)
1254 typedef typename _bi::list_av_1<A1>::type list_type;
1255 return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type(a1));
1258 template<class F, class A1, class A2>
1259 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_2<A1, A2>::type>
1260 BOOST_BIND(F f, A1 a1, A2 a2)
1262 typedef typename _bi::list_av_2<A1, A2>::type list_type;
1263 return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type(a1, a2));
1266 template<class F, class A1, class A2, class A3>
1267 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_3<A1, A2, A3>::type>
1268 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3)
1270 typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
1271 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3));
1274 template<class F, class A1, class A2, class A3, class A4>
1275 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
1276 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4)
1278 typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
1279 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4));
1282 template<class F, class A1, class A2, class A3, class A4, class A5>
1283 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
1284 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
1286 typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
1287 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
1290 template<class F, class A1, class A2, class A3, class A4, class A5, class A6>
1291 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
1292 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
1294 typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
1295 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
1298 template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
1299 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
1300 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
1302 typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
1303 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
1306 template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
1307 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
1308 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
1310 typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
1311 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
1314 template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
1315 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
1316 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
1318 typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
1319 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
1322 #endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
1324 // function pointers
1326 #define BOOST_BIND_CC
1327 #define BOOST_BIND_ST
1329 #include <boost/bind/bind_cc.hpp>
1331 #undef BOOST_BIND_CC
1332 #undef BOOST_BIND_ST
1334 #ifdef BOOST_BIND_ENABLE_STDCALL
1336 #define BOOST_BIND_CC __stdcall
1337 #define BOOST_BIND_ST
1339 #include <boost/bind/bind_cc.hpp>
1341 #undef BOOST_BIND_CC
1342 #undef BOOST_BIND_ST
1346 #ifdef BOOST_BIND_ENABLE_PASCAL
1348 #define BOOST_BIND_ST pascal
1349 #define BOOST_BIND_CC
1351 #include <boost/bind/bind_cc.hpp>
1353 #undef BOOST_BIND_ST
1354 #undef BOOST_BIND_CC
1358 // member function pointers
1360 #define BOOST_BIND_MF_NAME(X) X
1361 #define BOOST_BIND_MF_CC
1363 #include <boost/bind/bind_mf_cc.hpp>
1365 #undef BOOST_BIND_MF_NAME
1366 #undef BOOST_BIND_MF_CC
1368 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
1370 #define BOOST_BIND_MF_NAME(X) X##_stdcall
1371 #define BOOST_BIND_MF_CC __stdcall
1373 #include <boost/bind/bind_mf_cc.hpp>
1375 #undef BOOST_BIND_MF_NAME
1376 #undef BOOST_BIND_MF_CC
1380 // data member pointers
1382 template<class R, class T, class A1>
1383 _bi::bind_t< R, _mfi::dm<R, T>, typename _bi::list_av_1<A1>::type >
1384 BOOST_BIND(R T::*f, A1 a1)
1386 typedef _mfi::dm<R, T> F;
1387 typedef typename _bi::list_av_1<A1>::type list_type;
1388 return _bi::bind_t<R, F, list_type>(F(f), list_type(a1));
1391 } // namespace boost
1393 #ifndef BOOST_BIND_NO_PLACEHOLDERS
1395 # include <boost/bind/placeholders.hpp>
1400 # pragma warning(default: 4512) // assignment operator could not be generated
1401 # pragma warning(pop)
1404 #endif // #ifndef BOOST_BIND_HPP_INCLUDED