]> git.lyx.org Git - lyx.git/blob - boost/boost/bind.hpp
lib/configure.py: use \nonstopmode instead of -interaction=nonstopmode, from JMarc...
[lyx.git] / boost / boost / bind.hpp
1 #ifndef BOOST_BIND_HPP_INCLUDED
2 #define BOOST_BIND_HPP_INCLUDED
3
4 // MS compatible compilers support #pragma once
5
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
7 # pragma once
8 #endif
9
10 //
11 //  bind.hpp - binds function objects to arguments
12 //
13 //  Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd.
14 //  Copyright (c) 2001 David Abrahams
15 //  Copyright (c) 2005 Peter Dimov
16 //
17 // Distributed under the Boost Software License, Version 1.0. (See
18 // accompanying file LICENSE_1_0.txt or copy at
19 // http://www.boost.org/LICENSE_1_0.txt)
20 //
21 //  See http://www.boost.org/libs/bind/bind.html for documentation.
22 //
23
24 #include <boost/config.hpp>
25 #include <boost/ref.hpp>
26 #include <boost/mem_fn.hpp>
27 #include <boost/type.hpp>
28 #include <boost/bind/arg.hpp>
29 #include <boost/visit_each.hpp>
30 #include <boost/detail/workaround.hpp>
31
32 // Borland-specific bug, visit_each() silently fails to produce code
33
34 #if defined(__BORLANDC__)
35 #  define BOOST_BIND_VISIT_EACH boost::visit_each
36 #else
37 #  define BOOST_BIND_VISIT_EACH visit_each
38 #endif
39
40 #ifdef BOOST_MSVC
41 # pragma warning(push)
42 # pragma warning(disable: 4512) // assignment operator could not be generated
43 #endif
44
45 namespace boost
46 {
47
48 namespace _bi // implementation details
49 {
50
51 // result_traits
52
53 template<class R, class F> struct result_traits
54 {
55     typedef R type;
56 };
57
58 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
59
60 struct unspecified {};
61
62 template<class F> struct result_traits<unspecified, F>
63 {
64     typedef typename F::result_type type;
65 };
66
67 template<class F> struct result_traits< unspecified, reference_wrapper<F> >
68 {
69     typedef typename F::result_type type;
70 };
71
72 #endif
73
74 // ref_compare
75
76 template<class T> bool ref_compare(T const & a, T const & b, long)
77 {
78     return a == b;
79 }
80
81 template<class T> bool ref_compare(reference_wrapper<T> const & a, reference_wrapper<T> const & b, int)
82 {
83     return a.get_pointer() == b.get_pointer();
84 }
85
86 // bind_t forward declaration for listN
87
88 template<class R, class F, class L> class bind_t;
89
90 // value
91
92 template<class T> class value
93 {
94 public:
95
96     value(T const & t): t_(t) {}
97
98     T & get() { return t_; }
99     T const & get() const { return t_; }
100
101     bool operator==(value const & rhs) const
102     {
103         return t_ == rhs.t_;
104     }
105
106 private:
107
108     T t_;
109 };
110
111 // type
112
113 template<class T> class type {};
114
115 // unwrap
116
117 template<class F> inline F & unwrap(F * f, long)
118 {
119     return *f;
120 }
121
122 template<class F> inline F & unwrap(reference_wrapper<F> * f, int)
123 {
124     return f->get();
125 }
126
127 template<class F> inline F & unwrap(reference_wrapper<F> const * f, int)
128 {
129     return f->get();
130 }
131
132 #if !( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, <= 0x3004) )
133
134 template<class R, class T> inline _mfi::dm<R, T> unwrap(R T::* * pm, int)
135 {
136     return _mfi::dm<R, T>(*pm);
137 }
138
139 #if !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
140 // IBM/VisualAge 6.0 is not able to handle this overload.
141 template<class R, class T> inline _mfi::dm<R, T> unwrap(R T::* const * pm, int)
142 {
143     return _mfi::dm<R, T>(*pm);
144 }
145 #endif
146
147
148 #endif
149
150 // listN
151
152 class list0
153 {
154 public:
155
156     list0() {}
157
158     template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
159
160     template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
161
162     template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
163
164     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); }
165
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
168     template<class R, class F, class A> R operator()(type<R>, F & f, A &, long)
169     {
170         return unwrap(&f, 0)();
171     }
172
173     template<class R, class F, class A> R operator()(type<R>, F const & f, A &, long) const
174     {
175         return unwrap(&f, 0)();
176     }
177
178     template<class F, class A> void operator()(type<void>, F & f, A &, int)
179     {
180         unwrap(&f, 0)();
181     }
182
183     template<class F, class A> void operator()(type<void>, F const & f, A &, int) const
184     {
185         unwrap(&f, 0)();
186     }
187
188     template<class V> void accept(V &) const
189     {
190     }
191
192     bool operator==(list0 const &) const
193     {
194         return true;
195     }
196 };
197
198 template<class A1> class list1
199 {
200 public:
201
202     explicit list1(A1 a1): a1_(a1) {}
203
204     A1 operator[] (boost::arg<1>) const { return a1_; }
205
206     A1 operator[] (boost::arg<1> (*) ()) const { return a1_; }
207
208     template<class T> T & operator[] ( _bi::value<T> & v ) const { return v.get(); }
209
210     template<class T> T const & operator[] ( _bi::value<T> const & v ) const { return v.get(); }
211
212     template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
213
214     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); }
215
216     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); }
217
218     template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
219     {
220         return unwrap(&f, 0)(a[a1_]);
221     }
222
223     template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
224     {
225         return unwrap(&f, 0)(a[a1_]);
226     }
227
228     template<class F, class A> void operator()(type<void>, F & f, A & a, int)
229     {
230         unwrap(&f, 0)(a[a1_]);
231     }
232
233     template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
234     {
235         unwrap(&f, 0)(a[a1_]);
236     }
237
238     template<class V> void accept(V & v) const
239     {
240         BOOST_BIND_VISIT_EACH(v, a1_, 0);
241     }
242
243     bool operator==(list1 const & rhs) const
244     {
245         return ref_compare(a1_, rhs.a1_, 0);
246     }
247
248 private:
249
250     A1 a1_;
251 };
252
253 template<class A1, class A2> class list2
254 {
255 public:
256
257     list2(A1 a1, A2 a2): a1_(a1), a2_(a2) {}
258
259     A1 operator[] (boost::arg<1>) const { return a1_; }
260     A2 operator[] (boost::arg<2>) const { return a2_; }
261
262     A1 operator[] (boost::arg<1> (*) ()) const { return a1_; }
263     A2 operator[] (boost::arg<2> (*) ()) const { return a2_; }
264
265     template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
266
267     template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
268
269     template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
270
271     template<class R, class F, class L> typename result_traits<R, F>::type operator[] (bind_t<R, F, L> & b) const { return b.eval(*this); }
272
273     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); }
274
275     template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
276     {
277         return unwrap(&f, 0)(a[a1_], a[a2_]);
278     }
279
280     template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
281     {
282         return unwrap(&f, 0)(a[a1_], a[a2_]);
283     }
284
285     template<class F, class A> void operator()(type<void>, F & f, A & a, int)
286     {
287         unwrap(&f, 0)(a[a1_], a[a2_]);
288     }
289
290     template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
291     {
292         unwrap(&f, 0)(a[a1_], a[a2_]);
293     }
294
295     template<class V> void accept(V & v) const
296     {
297         BOOST_BIND_VISIT_EACH(v, a1_, 0);
298         BOOST_BIND_VISIT_EACH(v, a2_, 0);
299     }
300
301     bool operator==(list2 const & rhs) const
302     {
303         return ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0);
304     }
305
306 private:
307
308     A1 a1_;
309     A2 a2_;
310 };
311
312 template<class A1, class A2, class A3> class list3
313 {
314 public:
315
316     list3(A1 a1, A2 a2, A3 a3): a1_(a1), a2_(a2), a3_(a3) {}
317
318     A1 operator[] (boost::arg<1>) const { return a1_; }
319     A2 operator[] (boost::arg<2>) const { return a2_; }
320     A3 operator[] (boost::arg<3>) const { return a3_; }
321
322     A1 operator[] (boost::arg<1> (*) ()) const { return a1_; }
323     A2 operator[] (boost::arg<2> (*) ()) const { return a2_; }
324     A3 operator[] (boost::arg<3> (*) ()) const { return a3_; }
325
326     template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
327
328     template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
329
330     template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
331
332     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); }
333
334     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); }
335
336     template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
337     {
338         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_]);
339     }
340
341     template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
342     {
343         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_]);
344     }
345
346     template<class F, class A> void operator()(type<void>, F & f, A & a, int)
347     {
348         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_]);
349     }
350
351     template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
352     {
353         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_]);
354     }
355
356     template<class V> void accept(V & v) const
357     {
358         BOOST_BIND_VISIT_EACH(v, a1_, 0);
359         BOOST_BIND_VISIT_EACH(v, a2_, 0);
360         BOOST_BIND_VISIT_EACH(v, a3_, 0);
361     }
362
363     bool operator==(list3 const & rhs) const
364     {
365         return ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0);
366     }
367
368 private:
369
370     A1 a1_;
371     A2 a2_;
372     A3 a3_;
373 };
374
375 template<class A1, class A2, class A3, class A4> class list4
376 {
377 public:
378
379     list4(A1 a1, A2 a2, A3 a3, A4 a4): a1_(a1), a2_(a2), a3_(a3), a4_(a4) {}
380
381     A1 operator[] (boost::arg<1>) const { return a1_; }
382     A2 operator[] (boost::arg<2>) const { return a2_; }
383     A3 operator[] (boost::arg<3>) const { return a3_; }
384     A4 operator[] (boost::arg<4>) const { return a4_; }
385
386     A1 operator[] (boost::arg<1> (*) ()) const { return a1_; }
387     A2 operator[] (boost::arg<2> (*) ()) const { return a2_; }
388     A3 operator[] (boost::arg<3> (*) ()) const { return a3_; }
389     A4 operator[] (boost::arg<4> (*) ()) const { return a4_; }
390
391     template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
392
393     template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
394
395     template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
396
397     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); }
398
399     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); }
400
401     template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
402     {
403         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_]);
404     }
405
406     template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
407     {
408         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_]);
409     }
410
411     template<class F, class A> void operator()(type<void>, F & f, A & a, int)
412     {
413         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_]);
414     }
415
416     template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
417     {
418         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_]);
419     }
420
421     template<class V> void accept(V & v) const
422     {
423         BOOST_BIND_VISIT_EACH(v, a1_, 0);
424         BOOST_BIND_VISIT_EACH(v, a2_, 0);
425         BOOST_BIND_VISIT_EACH(v, a3_, 0);
426         BOOST_BIND_VISIT_EACH(v, a4_, 0);
427     }
428
429     bool operator==(list4 const & rhs) const
430     {
431         return
432             ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0) &&
433             ref_compare(a4_, rhs.a4_, 0);
434     }
435
436 private:
437
438     A1 a1_;
439     A2 a2_;
440     A3 a3_;
441     A4 a4_;
442 };
443
444 template<class A1, class A2, class A3, class A4, class A5> class list5
445 {
446 public:
447
448     list5(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5): a1_(a1), a2_(a2), a3_(a3), a4_(a4), a5_(a5) {}
449
450     A1 operator[] (boost::arg<1>) const { return a1_; }
451     A2 operator[] (boost::arg<2>) const { return a2_; }
452     A3 operator[] (boost::arg<3>) const { return a3_; }
453     A4 operator[] (boost::arg<4>) const { return a4_; }
454     A5 operator[] (boost::arg<5>) const { return a5_; }
455
456     A1 operator[] (boost::arg<1> (*) ()) const { return a1_; }
457     A2 operator[] (boost::arg<2> (*) ()) const { return a2_; }
458     A3 operator[] (boost::arg<3> (*) ()) const { return a3_; }
459     A4 operator[] (boost::arg<4> (*) ()) const { return a4_; }
460     A5 operator[] (boost::arg<5> (*) ()) const { return a5_; }
461
462     template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
463
464     template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
465
466     template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
467
468     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); }
469
470     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); }
471
472     template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
473     {
474         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_]);
475     }
476
477     template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
478     {
479         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_]);
480     }
481
482     template<class F, class A> void operator()(type<void>, F & f, A & a, int)
483     {
484         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_]);
485     }
486
487     template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
488     {
489         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_]);
490     }
491
492     template<class V> void accept(V & v) const
493     {
494         BOOST_BIND_VISIT_EACH(v, a1_, 0);
495         BOOST_BIND_VISIT_EACH(v, a2_, 0);
496         BOOST_BIND_VISIT_EACH(v, a3_, 0);
497         BOOST_BIND_VISIT_EACH(v, a4_, 0);
498         BOOST_BIND_VISIT_EACH(v, a5_, 0);
499     }
500
501     bool operator==(list5 const & rhs) const
502     {
503         return
504             ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0) &&
505             ref_compare(a4_, rhs.a4_, 0) && ref_compare(a5_, rhs.a5_, 0);
506     }
507
508 private:
509
510     A1 a1_;
511     A2 a2_;
512     A3 a3_;
513     A4 a4_;
514     A5 a5_;
515 };
516
517 template<class A1, class A2, class A3, class A4, class A5, class A6> class list6
518 {
519 public:
520
521     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) {}
522
523     A1 operator[] (boost::arg<1>) const { return a1_; }
524     A2 operator[] (boost::arg<2>) const { return a2_; }
525     A3 operator[] (boost::arg<3>) const { return a3_; }
526     A4 operator[] (boost::arg<4>) const { return a4_; }
527     A5 operator[] (boost::arg<5>) const { return a5_; }
528     A6 operator[] (boost::arg<6>) const { return a6_; }
529
530     A1 operator[] (boost::arg<1> (*) ()) const { return a1_; }
531     A2 operator[] (boost::arg<2> (*) ()) const { return a2_; }
532     A3 operator[] (boost::arg<3> (*) ()) const { return a3_; }
533     A4 operator[] (boost::arg<4> (*) ()) const { return a4_; }
534     A5 operator[] (boost::arg<5> (*) ()) const { return a5_; }
535     A6 operator[] (boost::arg<6> (*) ()) const { return a6_; }
536
537     template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
538
539     template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
540
541     template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
542
543     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); }
544
545     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); }
546
547     template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
548     {
549         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_]);
550     }
551
552     template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
553     {
554         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_]);
555     }
556
557     template<class F, class A> void operator()(type<void>, F & f, A & a, int)
558     {
559         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_]);
560     }
561
562     template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
563     {
564         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_]);
565     }
566
567     template<class V> void accept(V & v) const
568     {
569         BOOST_BIND_VISIT_EACH(v, a1_, 0);
570         BOOST_BIND_VISIT_EACH(v, a2_, 0);
571         BOOST_BIND_VISIT_EACH(v, a3_, 0);
572         BOOST_BIND_VISIT_EACH(v, a4_, 0);
573         BOOST_BIND_VISIT_EACH(v, a5_, 0);
574         BOOST_BIND_VISIT_EACH(v, a6_, 0);
575     }
576
577     bool operator==(list6 const & rhs) const
578     {
579         return
580             ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0) &&
581             ref_compare(a4_, rhs.a4_, 0) && ref_compare(a5_, rhs.a5_, 0) && ref_compare(a6_, rhs.a6_, 0);
582     }
583
584 private:
585
586     A1 a1_;
587     A2 a2_;
588     A3 a3_;
589     A4 a4_;
590     A5 a5_;
591     A6 a6_;
592 };
593
594 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> class list7
595 {
596 public:
597
598     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) {}
599
600     A1 operator[] (boost::arg<1>) const { return a1_; }
601     A2 operator[] (boost::arg<2>) const { return a2_; }
602     A3 operator[] (boost::arg<3>) const { return a3_; }
603     A4 operator[] (boost::arg<4>) const { return a4_; }
604     A5 operator[] (boost::arg<5>) const { return a5_; }
605     A6 operator[] (boost::arg<6>) const { return a6_; }
606     A7 operator[] (boost::arg<7>) const { return a7_; }
607
608     A1 operator[] (boost::arg<1> (*) ()) const { return a1_; }
609     A2 operator[] (boost::arg<2> (*) ()) const { return a2_; }
610     A3 operator[] (boost::arg<3> (*) ()) const { return a3_; }
611     A4 operator[] (boost::arg<4> (*) ()) const { return a4_; }
612     A5 operator[] (boost::arg<5> (*) ()) const { return a5_; }
613     A6 operator[] (boost::arg<6> (*) ()) const { return a6_; }
614     A7 operator[] (boost::arg<7> (*) ()) const { return a7_; }
615
616     template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
617
618     template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
619
620     template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
621
622     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); }
623
624     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); }
625
626     template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
627     {
628         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_]);
629     }
630
631     template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
632     {
633         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_]);
634     }
635
636     template<class F, class A> void operator()(type<void>, F & f, A & a, int)
637     {
638         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_]);
639     }
640
641     template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
642     {
643         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_]);
644     }
645
646     template<class V> void accept(V & v) const
647     {
648         BOOST_BIND_VISIT_EACH(v, a1_, 0);
649         BOOST_BIND_VISIT_EACH(v, a2_, 0);
650         BOOST_BIND_VISIT_EACH(v, a3_, 0);
651         BOOST_BIND_VISIT_EACH(v, a4_, 0);
652         BOOST_BIND_VISIT_EACH(v, a5_, 0);
653         BOOST_BIND_VISIT_EACH(v, a6_, 0);
654         BOOST_BIND_VISIT_EACH(v, a7_, 0);
655     }
656
657     bool operator==(list7 const & rhs) const
658     {
659         return
660             ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0) &&
661             ref_compare(a4_, rhs.a4_, 0) && ref_compare(a5_, rhs.a5_, 0) && ref_compare(a6_, rhs.a6_, 0) &&
662             ref_compare(a7_, rhs.a7_, 0);
663     }
664
665 private:
666
667     A1 a1_;
668     A2 a2_;
669     A3 a3_;
670     A4 a4_;
671     A5 a5_;
672     A6 a6_;
673     A7 a7_;
674 };
675
676 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> class list8
677 {
678 public:
679
680     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) {}
681
682     A1 operator[] (boost::arg<1>) const { return a1_; }
683     A2 operator[] (boost::arg<2>) const { return a2_; }
684     A3 operator[] (boost::arg<3>) const { return a3_; }
685     A4 operator[] (boost::arg<4>) const { return a4_; }
686     A5 operator[] (boost::arg<5>) const { return a5_; }
687     A6 operator[] (boost::arg<6>) const { return a6_; }
688     A7 operator[] (boost::arg<7>) const { return a7_; }
689     A8 operator[] (boost::arg<8>) const { return a8_; }
690
691     A1 operator[] (boost::arg<1> (*) ()) const { return a1_; }
692     A2 operator[] (boost::arg<2> (*) ()) const { return a2_; }
693     A3 operator[] (boost::arg<3> (*) ()) const { return a3_; }
694     A4 operator[] (boost::arg<4> (*) ()) const { return a4_; }
695     A5 operator[] (boost::arg<5> (*) ()) const { return a5_; }
696     A6 operator[] (boost::arg<6> (*) ()) const { return a6_; }
697     A7 operator[] (boost::arg<7> (*) ()) const { return a7_; }
698     A8 operator[] (boost::arg<8> (*) ()) const { return a8_; }
699
700     template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
701
702     template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
703
704     template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
705
706     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); }
707
708     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); }
709
710     template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
711     {
712         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_], a[a8_]);
713     }
714
715     template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
716     {
717         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_], a[a8_]);
718     }
719
720     template<class F, class A> void operator()(type<void>, F & f, A & a, int)
721     {
722         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_], a[a8_]);
723     }
724
725     template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
726     {
727         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_], a[a8_]);
728     }
729
730     template<class V> void accept(V & v) const
731     {
732         BOOST_BIND_VISIT_EACH(v, a1_, 0);
733         BOOST_BIND_VISIT_EACH(v, a2_, 0);
734         BOOST_BIND_VISIT_EACH(v, a3_, 0);
735         BOOST_BIND_VISIT_EACH(v, a4_, 0);
736         BOOST_BIND_VISIT_EACH(v, a5_, 0);
737         BOOST_BIND_VISIT_EACH(v, a6_, 0);
738         BOOST_BIND_VISIT_EACH(v, a7_, 0);
739         BOOST_BIND_VISIT_EACH(v, a8_, 0);
740     }
741
742     bool operator==(list8 const & rhs) const
743     {
744         return
745             ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0) &&
746             ref_compare(a4_, rhs.a4_, 0) && ref_compare(a5_, rhs.a5_, 0) && ref_compare(a6_, rhs.a6_, 0) &&
747             ref_compare(a7_, rhs.a7_, 0) && ref_compare(a8_, rhs.a8_, 0);
748     }
749
750 private:
751
752     A1 a1_;
753     A2 a2_;
754     A3 a3_;
755     A4 a4_;
756     A5 a5_;
757     A6 a6_;
758     A7 a7_;
759     A8 a8_;
760 };
761
762 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> class list9
763 {
764 public:
765
766     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) {}
767
768     A1 operator[] (boost::arg<1>) const { return a1_; }
769     A2 operator[] (boost::arg<2>) const { return a2_; }
770     A3 operator[] (boost::arg<3>) const { return a3_; }
771     A4 operator[] (boost::arg<4>) const { return a4_; }
772     A5 operator[] (boost::arg<5>) const { return a5_; }
773     A6 operator[] (boost::arg<6>) const { return a6_; }
774     A7 operator[] (boost::arg<7>) const { return a7_; }
775     A8 operator[] (boost::arg<8>) const { return a8_; }
776     A9 operator[] (boost::arg<9>) const { return a9_; }
777
778     A1 operator[] (boost::arg<1> (*) ()) const { return a1_; }
779     A2 operator[] (boost::arg<2> (*) ()) const { return a2_; }
780     A3 operator[] (boost::arg<3> (*) ()) const { return a3_; }
781     A4 operator[] (boost::arg<4> (*) ()) const { return a4_; }
782     A5 operator[] (boost::arg<5> (*) ()) const { return a5_; }
783     A6 operator[] (boost::arg<6> (*) ()) const { return a6_; }
784     A7 operator[] (boost::arg<7> (*) ()) const { return a7_; }
785     A8 operator[] (boost::arg<8> (*) ()) const { return a8_; }
786     A9 operator[] (boost::arg<9> (*) ()) const { return a9_; }
787
788     template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
789
790     template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
791
792     template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
793
794     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); }
795
796     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); }
797
798     template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
799     {
800         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_], a[a8_], a[a9_]);
801     }
802
803     template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
804     {
805         return unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_], a[a8_], a[a9_]);
806     }
807
808     template<class F, class A> void operator()(type<void>, F & f, A & a, int)
809     {
810         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_], a[a8_], a[a9_]);
811     }
812
813     template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
814     {
815         unwrap(&f, 0)(a[a1_], a[a2_], a[a3_], a[a4_], a[a5_], a[a6_], a[a7_], a[a8_], a[a9_]);
816     }
817
818     template<class V> void accept(V & v) const
819     {
820         BOOST_BIND_VISIT_EACH(v, a1_, 0);
821         BOOST_BIND_VISIT_EACH(v, a2_, 0);
822         BOOST_BIND_VISIT_EACH(v, a3_, 0);
823         BOOST_BIND_VISIT_EACH(v, a4_, 0);
824         BOOST_BIND_VISIT_EACH(v, a5_, 0);
825         BOOST_BIND_VISIT_EACH(v, a6_, 0);
826         BOOST_BIND_VISIT_EACH(v, a7_, 0);
827         BOOST_BIND_VISIT_EACH(v, a8_, 0);
828         BOOST_BIND_VISIT_EACH(v, a9_, 0);
829     }
830
831     bool operator==(list9 const & rhs) const
832     {
833         return
834             ref_compare(a1_, rhs.a1_, 0) && ref_compare(a2_, rhs.a2_, 0) && ref_compare(a3_, rhs.a3_, 0) &&
835             ref_compare(a4_, rhs.a4_, 0) && ref_compare(a5_, rhs.a5_, 0) && ref_compare(a6_, rhs.a6_, 0) &&
836             ref_compare(a7_, rhs.a7_, 0) && ref_compare(a8_, rhs.a8_, 0) && ref_compare(a9_, rhs.a9_, 0);
837     }
838
839 private:
840
841     A1 a1_;
842     A2 a2_;
843     A3 a3_;
844     A4 a4_;
845     A5 a5_;
846     A6 a6_;
847     A7 a7_;
848     A8 a8_;
849     A9 a9_;
850 };
851
852 // bind_t
853
854 #ifndef BOOST_NO_VOID_RETURNS
855
856 template<class R, class F, class L> class bind_t
857 {
858 public:
859
860     typedef bind_t this_type;
861
862     bind_t(F f, L const & l): f_(f), l_(l) {}
863
864 #define BOOST_BIND_RETURN return
865 #include <boost/bind/bind_template.hpp>
866 #undef BOOST_BIND_RETURN
867
868 };
869
870 #else
871
872 template<class R> struct bind_t_generator
873 {
874
875 template<class F, class L> class implementation
876 {
877 public:
878
879     typedef implementation this_type;
880
881     implementation(F f, L const & l): f_(f), l_(l) {}
882
883 #define BOOST_BIND_RETURN return
884 #include <boost/bind/bind_template.hpp>
885 #undef BOOST_BIND_RETURN
886
887 };
888
889 };
890
891 template<> struct bind_t_generator<void>
892 {
893
894 template<class F, class L> class implementation
895 {
896 private:
897
898     typedef void R;
899
900 public:
901
902     typedef implementation this_type;
903
904     implementation(F f, L const & l): f_(f), l_(l) {}
905
906 #define BOOST_BIND_RETURN
907 #include <boost/bind/bind_template.hpp>
908 #undef BOOST_BIND_RETURN
909
910 };
911
912 };
913
914 template<class R2, class F, class L> class bind_t: public bind_t_generator<R2>::BOOST_NESTED_TEMPLATE implementation<F, L>
915 {
916 public:
917
918     bind_t(F f, L const & l): bind_t_generator<R2>::BOOST_NESTED_TEMPLATE implementation<F, L>(f, l) {}
919
920 };
921
922 #endif
923
924 // function_equal
925
926 #ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
927
928 // put overloads in _bi, rely on ADL
929
930 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
931
932 template<class R, class F, class L> bool function_equal( bind_t<R, F, L> const & a, bind_t<R, F, L> const & b )
933 {
934     return a.compare(b);
935 }
936
937 # else
938
939 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 )
940 {
941     return a.compare(b);
942 }
943
944 # endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
945
946 #else // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
947
948 // put overloads in boost
949
950 } // namespace _bi
951
952 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
953
954 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 )
955 {
956     return a.compare(b);
957 }
958
959 # else
960
961 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 )
962 {
963     return a.compare(b);
964 }
965
966 # endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
967
968 namespace _bi
969 {
970
971 #endif // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
972
973 // add_value
974
975 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530)
976
977 template<class T> struct add_value
978 {
979     typedef _bi::value<T> type;
980 };
981
982 template<class T> struct add_value< value<T> >
983 {
984     typedef _bi::value<T> type;
985 };
986
987 template<class T> struct add_value< reference_wrapper<T> >
988 {
989     typedef reference_wrapper<T> type;
990 };
991
992 template<int I> struct add_value< arg<I> >
993 {
994     typedef boost::arg<I> type;
995 };
996
997 template<int I> struct add_value< arg<I> (*) () >
998 {
999     typedef boost::arg<I> (*type) ();
1000 };
1001
1002 template<class R, class F, class L> struct add_value< bind_t<R, F, L> >
1003 {
1004     typedef bind_t<R, F, L> type;
1005 };
1006
1007 #else
1008
1009 template<int I> struct _avt_0;
1010
1011 template<> struct _avt_0<1>
1012 {
1013     template<class T> struct inner
1014     {
1015         typedef T type;
1016     };
1017 };
1018
1019 template<> struct _avt_0<2>
1020 {
1021     template<class T> struct inner
1022     {
1023         typedef value<T> type;
1024     };
1025 };
1026
1027 typedef char (&_avt_r1) [1];
1028 typedef char (&_avt_r2) [2];
1029
1030 template<class T> _avt_r1 _avt_f(value<T>);
1031 template<class T> _avt_r1 _avt_f(reference_wrapper<T>);
1032 template<int I> _avt_r1 _avt_f(arg<I>);
1033 template<int I> _avt_r1 _avt_f(arg<I> (*) ());
1034 template<class R, class F, class L> _avt_r1 _avt_f(bind_t<R, F, L>);
1035
1036 _avt_r2 _avt_f(...);
1037
1038 template<class T> struct add_value
1039 {
1040     static T t();
1041     typedef typename _avt_0<sizeof(_avt_f(t()))>::template inner<T>::type type;
1042 };
1043
1044 #endif
1045
1046 // list_av_N
1047
1048 template<class A1> struct list_av_1
1049 {
1050     typedef typename add_value<A1>::type B1;
1051     typedef list1<B1> type;
1052 };
1053
1054 template<class A1, class A2> struct list_av_2
1055 {
1056     typedef typename add_value<A1>::type B1;
1057     typedef typename add_value<A2>::type B2;
1058     typedef list2<B1, B2> type;
1059 };
1060
1061 template<class A1, class A2, class A3> struct list_av_3
1062 {
1063     typedef typename add_value<A1>::type B1;
1064     typedef typename add_value<A2>::type B2;
1065     typedef typename add_value<A3>::type B3;
1066     typedef list3<B1, B2, B3> type;
1067 };
1068
1069 template<class A1, class A2, class A3, class A4> struct list_av_4
1070 {
1071     typedef typename add_value<A1>::type B1;
1072     typedef typename add_value<A2>::type B2;
1073     typedef typename add_value<A3>::type B3;
1074     typedef typename add_value<A4>::type B4;
1075     typedef list4<B1, B2, B3, B4> type;
1076 };
1077
1078 template<class A1, class A2, class A3, class A4, class A5> struct list_av_5
1079 {
1080     typedef typename add_value<A1>::type B1;
1081     typedef typename add_value<A2>::type B2;
1082     typedef typename add_value<A3>::type B3;
1083     typedef typename add_value<A4>::type B4;
1084     typedef typename add_value<A5>::type B5;
1085     typedef list5<B1, B2, B3, B4, B5> type;
1086 };
1087
1088 template<class A1, class A2, class A3, class A4, class A5, class A6> struct list_av_6
1089 {
1090     typedef typename add_value<A1>::type B1;
1091     typedef typename add_value<A2>::type B2;
1092     typedef typename add_value<A3>::type B3;
1093     typedef typename add_value<A4>::type B4;
1094     typedef typename add_value<A5>::type B5;
1095     typedef typename add_value<A6>::type B6;
1096     typedef list6<B1, B2, B3, B4, B5, B6> type;
1097 };
1098
1099 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct list_av_7
1100 {
1101     typedef typename add_value<A1>::type B1;
1102     typedef typename add_value<A2>::type B2;
1103     typedef typename add_value<A3>::type B3;
1104     typedef typename add_value<A4>::type B4;
1105     typedef typename add_value<A5>::type B5;
1106     typedef typename add_value<A6>::type B6;
1107     typedef typename add_value<A7>::type B7;
1108     typedef list7<B1, B2, B3, B4, B5, B6, B7> type;
1109 };
1110
1111 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct list_av_8
1112 {
1113     typedef typename add_value<A1>::type B1;
1114     typedef typename add_value<A2>::type B2;
1115     typedef typename add_value<A3>::type B3;
1116     typedef typename add_value<A4>::type B4;
1117     typedef typename add_value<A5>::type B5;
1118     typedef typename add_value<A6>::type B6;
1119     typedef typename add_value<A7>::type B7;
1120     typedef typename add_value<A8>::type B8;
1121     typedef list8<B1, B2, B3, B4, B5, B6, B7, B8> type;
1122 };
1123
1124 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> struct list_av_9
1125 {
1126     typedef typename add_value<A1>::type B1;
1127     typedef typename add_value<A2>::type B2;
1128     typedef typename add_value<A3>::type B3;
1129     typedef typename add_value<A4>::type B4;
1130     typedef typename add_value<A5>::type B5;
1131     typedef typename add_value<A6>::type B6;
1132     typedef typename add_value<A7>::type B7;
1133     typedef typename add_value<A8>::type B8;
1134     typedef typename add_value<A9>::type B9;
1135     typedef list9<B1, B2, B3, B4, B5, B6, B7, B8, B9> type;
1136 };
1137
1138 // operator!
1139
1140 struct logical_not
1141 {
1142     template<class V> bool operator()(V const & v) const { return !v; }
1143 };
1144
1145 template<class R, class F, class L>
1146     bind_t< bool, logical_not, list1< bind_t<R, F, L> > >
1147     operator! (bind_t<R, F, L> const & f)
1148 {
1149     typedef list1< bind_t<R, F, L> > list_type;
1150     return bind_t<bool, logical_not, list_type> ( logical_not(), list_type(f) );
1151 }
1152
1153 // relational operators
1154
1155 #define BOOST_BIND_OPERATOR( op, name ) \
1156 \
1157 struct name \
1158 { \
1159     template<class V, class W> bool operator()(V const & v, W const & w) const { return v op w; } \
1160 }; \
1161  \
1162 template<class R, class F, class L, class A2> \
1163     bind_t< bool, name, list2< bind_t<R, F, L>, typename add_value<A2>::type > > \
1164     operator op (bind_t<R, F, L> const & f, A2 a2) \
1165 { \
1166     typedef typename add_value<A2>::type B2; \
1167     typedef list2< bind_t<R, F, L>, B2> list_type; \
1168     return bind_t<bool, name, list_type> ( name(), list_type(f, a2) ); \
1169 }
1170
1171 BOOST_BIND_OPERATOR( ==, equal )
1172 BOOST_BIND_OPERATOR( !=, not_equal )
1173
1174 BOOST_BIND_OPERATOR( <, less )
1175 BOOST_BIND_OPERATOR( <=, less_equal )
1176
1177 BOOST_BIND_OPERATOR( >, greater )
1178 BOOST_BIND_OPERATOR( >=, greater_equal )
1179
1180 #undef BOOST_BIND_OPERATOR
1181
1182 #if defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3)
1183
1184 // resolve ambiguity with rel_ops
1185
1186 #define BOOST_BIND_OPERATOR( op, name ) \
1187 \
1188 template<class R, class F, class L> \
1189     bind_t< bool, name, list2< bind_t<R, F, L>, bind_t<R, F, L> > > \
1190     operator op (bind_t<R, F, L> const & f, bind_t<R, F, L> const & g) \
1191 { \
1192     typedef list2< bind_t<R, F, L>, bind_t<R, F, L> > list_type; \
1193     return bind_t<bool, name, list_type> ( name(), list_type(f, g) ); \
1194 }
1195
1196 BOOST_BIND_OPERATOR( !=, not_equal )
1197 BOOST_BIND_OPERATOR( <=, less_equal )
1198 BOOST_BIND_OPERATOR( >, greater )
1199 BOOST_BIND_OPERATOR( >=, greater_equal )
1200
1201 #endif
1202
1203 } // namespace _bi
1204
1205 // visit_each
1206
1207 template<class V, class T> void visit_each(V & v, _bi::value<T> const & t, int)
1208 {
1209     BOOST_BIND_VISIT_EACH(v, t.get(), 0);
1210 }
1211
1212 template<class V, class R, class F, class L> void visit_each(V & v, _bi::bind_t<R, F, L> const & t, int)
1213 {
1214     t.accept(v);
1215 }
1216
1217 // bind
1218
1219 #ifndef BOOST_BIND
1220 #define BOOST_BIND bind
1221 #endif
1222
1223 // generic function objects
1224
1225 template<class R, class F>
1226     _bi::bind_t<R, F, _bi::list0>
1227     BOOST_BIND(F f)
1228 {
1229     typedef _bi::list0 list_type;
1230     return _bi::bind_t<R, F, list_type> (f, list_type());
1231 }
1232
1233 template<class R, class F, class A1>
1234     _bi::bind_t<R, F, typename _bi::list_av_1<A1>::type>
1235     BOOST_BIND(F f, A1 a1)
1236 {
1237     typedef typename _bi::list_av_1<A1>::type list_type;
1238     return _bi::bind_t<R, F, list_type> (f, list_type(a1));
1239 }
1240
1241 template<class R, class F, class A1, class A2>
1242     _bi::bind_t<R, F, typename _bi::list_av_2<A1, A2>::type>
1243     BOOST_BIND(F f, A1 a1, A2 a2)
1244 {
1245     typedef typename _bi::list_av_2<A1, A2>::type list_type;
1246     return _bi::bind_t<R, F, list_type> (f, list_type(a1, a2));
1247 }
1248
1249 template<class R, class F, class A1, class A2, class A3>
1250     _bi::bind_t<R, F, typename _bi::list_av_3<A1, A2, A3>::type>
1251     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3)
1252 {
1253     typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
1254     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3));
1255 }
1256
1257 template<class R, class F, class A1, class A2, class A3, class A4>
1258     _bi::bind_t<R, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
1259     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4)
1260 {
1261     typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
1262     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4));
1263 }
1264
1265 template<class R, class F, class A1, class A2, class A3, class A4, class A5>
1266     _bi::bind_t<R, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
1267     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
1268 {
1269     typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
1270     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
1271 }
1272
1273 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6>
1274     _bi::bind_t<R, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
1275     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
1276 {
1277     typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
1278     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
1279 }
1280
1281 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
1282     _bi::bind_t<R, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
1283     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
1284 {
1285     typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
1286     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
1287 }
1288
1289 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
1290     _bi::bind_t<R, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
1291     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
1292 {
1293     typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
1294     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
1295 }
1296
1297 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
1298     _bi::bind_t<R, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
1299     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
1300 {
1301     typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
1302     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
1303 }
1304
1305 // generic function objects, alternative syntax
1306
1307 template<class R, class F>
1308     _bi::bind_t<R, F, _bi::list0>
1309     BOOST_BIND(boost::type<R>, F f)
1310 {
1311     typedef _bi::list0 list_type;
1312     return _bi::bind_t<R, F, list_type> (f, list_type());
1313 }
1314
1315 template<class R, class F, class A1>
1316     _bi::bind_t<R, F, typename _bi::list_av_1<A1>::type>
1317     BOOST_BIND(boost::type<R>, F f, A1 a1)
1318 {
1319     typedef typename _bi::list_av_1<A1>::type list_type;
1320     return _bi::bind_t<R, F, list_type> (f, list_type(a1));
1321 }
1322
1323 template<class R, class F, class A1, class A2>
1324     _bi::bind_t<R, F, typename _bi::list_av_2<A1, A2>::type>
1325     BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2)
1326 {
1327     typedef typename _bi::list_av_2<A1, A2>::type list_type;
1328     return _bi::bind_t<R, F, list_type> (f, list_type(a1, a2));
1329 }
1330
1331 template<class R, class F, class A1, class A2, class A3>
1332     _bi::bind_t<R, F, typename _bi::list_av_3<A1, A2, A3>::type>
1333     BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3)
1334 {
1335     typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
1336     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3));
1337 }
1338
1339 template<class R, class F, class A1, class A2, class A3, class A4>
1340     _bi::bind_t<R, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
1341     BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4)
1342 {
1343     typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
1344     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4));
1345 }
1346
1347 template<class R, class F, class A1, class A2, class A3, class A4, class A5>
1348     _bi::bind_t<R, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
1349     BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
1350 {
1351     typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
1352     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
1353 }
1354
1355 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6>
1356     _bi::bind_t<R, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
1357     BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
1358 {
1359     typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
1360     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
1361 }
1362
1363 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
1364     _bi::bind_t<R, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
1365     BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
1366 {
1367     typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
1368     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
1369 }
1370
1371 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
1372     _bi::bind_t<R, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
1373     BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
1374 {
1375     typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
1376     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
1377 }
1378
1379 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
1380     _bi::bind_t<R, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
1381     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)
1382 {
1383     typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
1384     return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
1385 }
1386
1387 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
1388
1389 // adaptable function objects
1390
1391 template<class F>
1392     _bi::bind_t<_bi::unspecified, F, _bi::list0>
1393     BOOST_BIND(F f)
1394 {
1395     typedef _bi::list0 list_type;
1396     return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type());
1397 }
1398
1399 template<class F, class A1>
1400     _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_1<A1>::type>
1401     BOOST_BIND(F f, A1 a1)
1402 {
1403     typedef typename _bi::list_av_1<A1>::type list_type;
1404     return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type(a1));
1405 }
1406
1407 template<class F, class A1, class A2>
1408     _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_2<A1, A2>::type>
1409     BOOST_BIND(F f, A1 a1, A2 a2)
1410 {
1411     typedef typename _bi::list_av_2<A1, A2>::type list_type;
1412     return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type(a1, a2));
1413 }
1414
1415 template<class F, class A1, class A2, class A3>
1416     _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_3<A1, A2, A3>::type>
1417     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3)
1418 {
1419     typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
1420     return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3));
1421 }
1422
1423 template<class F, class A1, class A2, class A3, class A4>
1424     _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
1425     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4)
1426 {
1427     typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
1428     return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4));
1429 }
1430
1431 template<class F, class A1, class A2, class A3, class A4, class A5>
1432     _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
1433     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
1434 {
1435     typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
1436     return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
1437 }
1438
1439 template<class F, class A1, class A2, class A3, class A4, class A5, class A6>
1440     _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
1441     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
1442 {
1443     typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
1444     return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
1445 }
1446
1447 template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
1448     _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
1449     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
1450 {
1451     typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
1452     return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
1453 }
1454
1455 template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
1456     _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
1457     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
1458 {
1459     typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
1460     return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
1461 }
1462
1463 template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
1464     _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
1465     BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
1466 {
1467     typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
1468     return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
1469 }
1470
1471 #endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
1472
1473 // function pointers
1474
1475 #define BOOST_BIND_CC
1476 #define BOOST_BIND_ST
1477
1478 #include <boost/bind/bind_cc.hpp>
1479
1480 #undef BOOST_BIND_CC
1481 #undef BOOST_BIND_ST
1482
1483 #ifdef BOOST_BIND_ENABLE_STDCALL
1484
1485 #define BOOST_BIND_CC __stdcall
1486 #define BOOST_BIND_ST
1487
1488 #include <boost/bind/bind_cc.hpp>
1489
1490 #undef BOOST_BIND_CC
1491 #undef BOOST_BIND_ST
1492
1493 #endif
1494
1495 #ifdef BOOST_BIND_ENABLE_FASTCALL
1496
1497 #define BOOST_BIND_CC __fastcall
1498 #define BOOST_BIND_ST
1499
1500 #include <boost/bind/bind_cc.hpp>
1501
1502 #undef BOOST_BIND_CC
1503 #undef BOOST_BIND_ST
1504
1505 #endif
1506
1507 #ifdef BOOST_BIND_ENABLE_PASCAL
1508
1509 #define BOOST_BIND_ST pascal
1510 #define BOOST_BIND_CC
1511
1512 #include <boost/bind/bind_cc.hpp>
1513
1514 #undef BOOST_BIND_ST
1515 #undef BOOST_BIND_CC
1516
1517 #endif
1518
1519 // member function pointers
1520
1521 #define BOOST_BIND_MF_NAME(X) X
1522 #define BOOST_BIND_MF_CC
1523
1524 #include <boost/bind/bind_mf_cc.hpp>
1525
1526 #undef BOOST_BIND_MF_NAME
1527 #undef BOOST_BIND_MF_CC
1528
1529 #ifdef BOOST_MEM_FN_ENABLE_CDECL
1530
1531 #define BOOST_BIND_MF_NAME(X) X##_cdecl
1532 #define BOOST_BIND_MF_CC __cdecl
1533
1534 #include <boost/bind/bind_mf_cc.hpp>
1535
1536 #undef BOOST_BIND_MF_NAME
1537 #undef BOOST_BIND_MF_CC
1538
1539 #endif
1540
1541 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
1542
1543 #define BOOST_BIND_MF_NAME(X) X##_stdcall
1544 #define BOOST_BIND_MF_CC __stdcall
1545
1546 #include <boost/bind/bind_mf_cc.hpp>
1547
1548 #undef BOOST_BIND_MF_NAME
1549 #undef BOOST_BIND_MF_CC
1550
1551 #endif
1552
1553 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
1554
1555 #define BOOST_BIND_MF_NAME(X) X##_fastcall
1556 #define BOOST_BIND_MF_CC __fastcall
1557
1558 #include <boost/bind/bind_mf_cc.hpp>
1559
1560 #undef BOOST_BIND_MF_NAME
1561 #undef BOOST_BIND_MF_CC
1562
1563 #endif
1564
1565 // data member pointers
1566
1567 /*
1568
1569 #if defined(__GNUC__) && (__GNUC__ == 2)
1570
1571 namespace _bi
1572 {
1573
1574 template<class T> struct add_cref
1575 {
1576     typedef T const & type;
1577 };
1578
1579 template<class T> struct add_cref< T & >
1580 {
1581     typedef T const & type;
1582 };
1583
1584 template<> struct add_cref<void>
1585 {
1586     typedef void type;
1587 };
1588
1589 } // namespace _bi
1590
1591 template<class R, class T, class A1>
1592 _bi::bind_t< typename _bi::add_cref<R>::type, _mfi::dm<R, T>, typename _bi::list_av_1<A1>::type >
1593     BOOST_BIND(R T::*f, A1 a1)
1594 {
1595     typedef _mfi::dm<R, T> F;
1596     typedef typename _bi::list_av_1<A1>::type list_type;
1597     return _bi::bind_t<typename _bi::add_cref<R>::type, F, list_type>(F(f), list_type(a1));
1598 }
1599
1600 #else
1601
1602 template<class R, class T, class A1>
1603 _bi::bind_t< R const &, _mfi::dm<R, T>, typename _bi::list_av_1<A1>::type >
1604     BOOST_BIND(R T::*f, A1 a1)
1605 {
1606     typedef _mfi::dm<R, T> F;
1607     typedef typename _bi::list_av_1<A1>::type list_type;
1608     return _bi::bind_t<R const &, F, list_type>(F(f), list_type(a1));
1609 }
1610
1611 #endif
1612
1613 */
1614
1615 template<class R, class T, class A1>
1616 _bi::bind_t< R, _mfi::dm<R, T>, typename _bi::list_av_1<A1>::type >
1617     BOOST_BIND(R T::*f, A1 a1)
1618 {
1619     typedef _mfi::dm<R, T> F;
1620     typedef typename _bi::list_av_1<A1>::type list_type;
1621     return _bi::bind_t<R, F, list_type>( F(f), list_type(a1) );
1622 }
1623
1624 } // namespace boost
1625
1626 #ifndef BOOST_BIND_NO_PLACEHOLDERS
1627
1628 # include <boost/bind/placeholders.hpp>
1629
1630 #endif
1631
1632 #ifdef BOOST_MSVC
1633 # pragma warning(default: 4512) // assignment operator could not be generated
1634 # pragma warning(pop)
1635 #endif
1636
1637 #endif // #ifndef BOOST_BIND_HPP_INCLUDED