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