fix doc example typo
[boost.git] / boost / bind / bind.hpp
blob1e5c9e032490ed8b2ed2ff3469fcd7053e48cd10
1 #ifndef BOOST_BIND_BIND_HPP_INCLUDED
2 #define BOOST_BIND_BIND_HPP_INCLUDED
4 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
7 # pragma once
8 #endif
11 // bind.hpp - binds function objects to arguments
13 // Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd.
14 // Copyright (c) 2001 David Abrahams
15 // Copyright (c) 2005 Peter Dimov
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)
21 // See http://www.boost.org/libs/bind/bind.html for documentation.
24 #include <boost/config.hpp>
25 #include <boost/ref.hpp>
26 #include <boost/mem_fn.hpp>
27 #include <boost/type.hpp>
28 #include <boost/is_placeholder.hpp>
29 #include <boost/bind/arg.hpp>
30 #include <boost/detail/workaround.hpp>
31 #include <boost/visit_each.hpp>
33 // Borland-specific bug, visit_each() silently fails to produce code
35 #if defined(__BORLANDC__)
36 # define BOOST_BIND_VISIT_EACH boost::visit_each
37 #else
38 # define BOOST_BIND_VISIT_EACH visit_each
39 #endif
41 #include <boost/bind/storage.hpp>
43 #ifdef BOOST_MSVC
44 # pragma warning(push)
45 # pragma warning(disable: 4512) // assignment operator could not be generated
46 #endif
48 namespace boost
51 template<class T> class weak_ptr;
53 namespace _bi // implementation details
56 // result_traits
58 template<class R, class F> struct result_traits
60 typedef R type;
63 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
65 struct unspecified {};
67 template<class F> struct result_traits<unspecified, F>
69 typedef typename F::result_type type;
72 template<class F> struct result_traits< unspecified, reference_wrapper<F> >
74 typedef typename F::result_type type;
77 #endif
79 // ref_compare
81 template<class T> bool ref_compare( T const & a, T const & b, long )
83 return a == b;
86 template<int I> bool ref_compare( arg<I> const &, arg<I> const &, int )
88 return true;
91 template<int I> bool ref_compare( arg<I> (*) (), arg<I> (*) (), int )
93 return true;
96 template<class T> bool ref_compare( reference_wrapper<T> const & a, reference_wrapper<T> const & b, int )
98 return a.get_pointer() == b.get_pointer();
101 // bind_t forward declaration for listN
103 template<class R, class F, class L> class bind_t;
105 template<class R, class F, class L> bool ref_compare( bind_t<R, F, L> const & a, bind_t<R, F, L> const & b, int )
107 return a.compare( b );
110 // value
112 template<class T> class value
114 public:
116 value(T const & t): t_(t) {}
118 T & get() { return t_; }
119 T const & get() const { return t_; }
121 bool operator==(value const & rhs) const
123 return t_ == rhs.t_;
126 private:
128 T t_;
131 // ref_compare for weak_ptr
133 template<class T> bool ref_compare( value< weak_ptr<T> > const & a, value< weak_ptr<T> > const & b, int )
135 return !(a.get() < b.get()) && !(b.get() < a.get());
138 // type
140 template<class T> class type {};
142 // unwrap
144 template<class F> struct unwrapper
146 static inline F & unwrap( F & f, long )
148 return f;
151 template<class F2> static inline F2 & unwrap( reference_wrapper<F2> rf, int )
153 return rf.get();
156 template<class R, class T> static inline _mfi::dm<R, T> unwrap( R T::* pm, int )
158 return _mfi::dm<R, T>( pm );
162 // listN
164 class list0
166 public:
168 list0() {}
170 template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
172 template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
174 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
176 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); }
178 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); }
180 template<class R, class F, class A> R operator()(type<R>, F & f, A &, long)
182 return unwrapper<F>::unwrap(f, 0)();
185 template<class R, class F, class A> R operator()(type<R>, F const & f, A &, long) const
187 return unwrapper<F const>::unwrap(f, 0)();
190 template<class F, class A> void operator()(type<void>, F & f, A &, int)
192 unwrapper<F>::unwrap(f, 0)();
195 template<class F, class A> void operator()(type<void>, F const & f, A &, int) const
197 unwrapper<F const>::unwrap(f, 0)();
200 template<class V> void accept(V &) const
204 bool operator==(list0 const &) const
206 return true;
210 template< class A1 > class list1: private storage1< A1 >
212 private:
214 typedef storage1< A1 > base_type;
216 public:
218 explicit list1( A1 a1 ): base_type( a1 ) {}
220 A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
222 A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
224 template<class T> T & operator[] ( _bi::value<T> & v ) const { return v.get(); }
226 template<class T> T const & operator[] ( _bi::value<T> const & v ) const { return v.get(); }
228 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
230 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); }
232 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); }
234 template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
236 return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_]);
239 template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
241 return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_]);
244 template<class F, class A> void operator()(type<void>, F & f, A & a, int)
246 unwrapper<F>::unwrap(f, 0)(a[base_type::a1_]);
249 template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
251 unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_]);
254 template<class V> void accept(V & v) const
256 base_type::accept(v);
259 bool operator==(list1 const & rhs) const
261 return ref_compare(base_type::a1_, rhs.a1_, 0);
265 struct logical_and;
266 struct logical_or;
268 template< class A1, class A2 > class list2: private storage2< A1, A2 >
270 private:
272 typedef storage2< A1, A2 > base_type;
274 public:
276 list2( A1 a1, A2 a2 ): base_type( a1, a2 ) {}
278 A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
279 A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
281 A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
282 A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
284 template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
286 template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
288 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
290 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); }
292 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); }
294 template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
296 return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
299 template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
301 return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
304 template<class F, class A> void operator()(type<void>, F & f, A & a, int)
306 unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
309 template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
311 unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
314 template<class A> bool operator()( type<bool>, logical_and & /*f*/, A & a, int )
316 return a[ base_type::a1_ ] && a[ base_type::a2_ ];
319 template<class A> bool operator()( type<bool>, logical_and const & /*f*/, A & a, int ) const
321 return a[ base_type::a1_ ] && a[ base_type::a2_ ];
324 template<class A> bool operator()( type<bool>, logical_or & /*f*/, A & a, int )
326 return a[ base_type::a1_ ] || a[ base_type::a2_ ];
329 template<class A> bool operator()( type<bool>, logical_or const & /*f*/, A & a, int ) const
331 return a[ base_type::a1_ ] || a[ base_type::a2_ ];
334 template<class V> void accept(V & v) const
336 base_type::accept(v);
339 bool operator==(list2 const & rhs) const
341 return ref_compare(base_type::a1_, rhs.a1_, 0) && ref_compare(base_type::a2_, rhs.a2_, 0);
345 template< class A1, class A2, class A3 > class list3: private storage3< A1, A2, A3 >
347 private:
349 typedef storage3< A1, A2, A3 > base_type;
351 public:
353 list3( A1 a1, A2 a2, A3 a3 ): base_type( a1, a2, a3 ) {}
355 A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
356 A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
357 A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
359 A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
360 A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
361 A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
363 template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
365 template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
367 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
369 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); }
371 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); }
373 template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
375 return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
378 template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
380 return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
383 template<class F, class A> void operator()(type<void>, F & f, A & a, int)
385 unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
388 template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
390 unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
393 template<class V> void accept(V & v) const
395 base_type::accept(v);
398 bool operator==(list3 const & rhs) const
400 return
402 ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
403 ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
404 ref_compare( base_type::a3_, rhs.a3_, 0 );
408 template< class A1, class A2, class A3, class A4 > class list4: private storage4< A1, A2, A3, A4 >
410 private:
412 typedef storage4< A1, A2, A3, A4 > base_type;
414 public:
416 list4( A1 a1, A2 a2, A3 a3, A4 a4 ): base_type( a1, a2, a3, a4 ) {}
418 A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
419 A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
420 A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
421 A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
423 A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
424 A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
425 A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
426 A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
428 template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
430 template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
432 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
434 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); }
436 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); }
438 template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
440 return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]);
443 template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
445 return unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]);
448 template<class F, class A> void operator()(type<void>, F & f, A & a, int)
450 unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]);
453 template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
455 unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]);
458 template<class V> void accept(V & v) const
460 base_type::accept(v);
463 bool operator==(list4 const & rhs) const
465 return
467 ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
468 ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
469 ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
470 ref_compare( base_type::a4_, rhs.a4_, 0 );
474 template< class A1, class A2, class A3, class A4, class A5 > class list5: private storage5< A1, A2, A3, A4, A5 >
476 private:
478 typedef storage5< A1, A2, A3, A4, A5 > base_type;
480 public:
482 list5( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 ): base_type( a1, a2, a3, a4, a5 ) {}
484 A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
485 A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
486 A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
487 A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
488 A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
490 A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
491 A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
492 A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
493 A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
494 A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
496 template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
498 template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
500 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
502 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); }
504 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); }
506 template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
508 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_]);
511 template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
513 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_]);
516 template<class F, class A> void operator()(type<void>, F & f, A & a, int)
518 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_]);
521 template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
523 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_]);
526 template<class V> void accept(V & v) const
528 base_type::accept(v);
531 bool operator==(list5 const & rhs) const
533 return
535 ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
536 ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
537 ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
538 ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
539 ref_compare( base_type::a5_, rhs.a5_, 0 );
543 template<class A1, class A2, class A3, class A4, class A5, class A6> class list6: private storage6< A1, A2, A3, A4, A5, A6 >
545 private:
547 typedef storage6< A1, A2, A3, A4, A5, A6 > base_type;
549 public:
551 list6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6 ): base_type( a1, a2, a3, a4, a5, a6 ) {}
553 A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
554 A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
555 A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
556 A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
557 A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
558 A6 operator[] (boost::arg<6>) const { return base_type::a6_; }
560 A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
561 A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
562 A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
563 A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
564 A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
565 A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; }
567 template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
569 template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
571 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
573 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); }
575 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); }
577 template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
579 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_]);
582 template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
584 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_]);
587 template<class F, class A> void operator()(type<void>, F & f, A & a, int)
589 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_]);
592 template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
594 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_]);
597 template<class V> void accept(V & v) const
599 base_type::accept(v);
602 bool operator==(list6 const & rhs) const
604 return
606 ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
607 ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
608 ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
609 ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
610 ref_compare( base_type::a5_, rhs.a5_, 0 ) &&
611 ref_compare( base_type::a6_, rhs.a6_, 0 );
615 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 >
617 private:
619 typedef storage7< A1, A2, A3, A4, A5, A6, A7 > base_type;
621 public:
623 list7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7 ): base_type( a1, a2, a3, a4, a5, a6, a7 ) {}
625 A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
626 A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
627 A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
628 A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
629 A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
630 A6 operator[] (boost::arg<6>) const { return base_type::a6_; }
631 A7 operator[] (boost::arg<7>) const { return base_type::a7_; }
633 A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
634 A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
635 A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
636 A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
637 A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
638 A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; }
639 A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; }
641 template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
643 template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
645 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
647 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); }
649 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); }
651 template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
653 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_]);
656 template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
658 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_]);
661 template<class F, class A> void operator()(type<void>, F & f, A & a, int)
663 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_]);
666 template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
668 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_]);
671 template<class V> void accept(V & v) const
673 base_type::accept(v);
676 bool operator==(list7 const & rhs) const
678 return
680 ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
681 ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
682 ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
683 ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
684 ref_compare( base_type::a5_, rhs.a5_, 0 ) &&
685 ref_compare( base_type::a6_, rhs.a6_, 0 ) &&
686 ref_compare( base_type::a7_, rhs.a7_, 0 );
690 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 >
692 private:
694 typedef storage8< A1, A2, A3, A4, A5, A6, A7, A8 > base_type;
696 public:
698 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 ) {}
700 A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
701 A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
702 A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
703 A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
704 A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
705 A6 operator[] (boost::arg<6>) const { return base_type::a6_; }
706 A7 operator[] (boost::arg<7>) const { return base_type::a7_; }
707 A8 operator[] (boost::arg<8>) const { return base_type::a8_; }
709 A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
710 A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
711 A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
712 A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
713 A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
714 A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; }
715 A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; }
716 A8 operator[] (boost::arg<8> (*) ()) const { return base_type::a8_; }
718 template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
720 template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
722 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
724 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); }
726 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); }
728 template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
730 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_]);
733 template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
735 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_]);
738 template<class F, class A> void operator()(type<void>, F & f, A & a, int)
740 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_]);
743 template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
745 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_]);
748 template<class V> void accept(V & v) const
750 base_type::accept(v);
753 bool operator==(list8 const & rhs) const
755 return
757 ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
758 ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
759 ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
760 ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
761 ref_compare( base_type::a5_, rhs.a5_, 0 ) &&
762 ref_compare( base_type::a6_, rhs.a6_, 0 ) &&
763 ref_compare( base_type::a7_, rhs.a7_, 0 ) &&
764 ref_compare( base_type::a8_, rhs.a8_, 0 );
768 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 >
770 private:
772 typedef storage9< A1, A2, A3, A4, A5, A6, A7, A8, A9 > base_type;
774 public:
776 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 ) {}
778 A1 operator[] (boost::arg<1>) const { return base_type::a1_; }
779 A2 operator[] (boost::arg<2>) const { return base_type::a2_; }
780 A3 operator[] (boost::arg<3>) const { return base_type::a3_; }
781 A4 operator[] (boost::arg<4>) const { return base_type::a4_; }
782 A5 operator[] (boost::arg<5>) const { return base_type::a5_; }
783 A6 operator[] (boost::arg<6>) const { return base_type::a6_; }
784 A7 operator[] (boost::arg<7>) const { return base_type::a7_; }
785 A8 operator[] (boost::arg<8>) const { return base_type::a8_; }
786 A9 operator[] (boost::arg<9>) const { return base_type::a9_; }
788 A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; }
789 A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; }
790 A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; }
791 A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; }
792 A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; }
793 A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; }
794 A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; }
795 A8 operator[] (boost::arg<8> (*) ()) const { return base_type::a8_; }
796 A9 operator[] (boost::arg<9> (*) ()) const { return base_type::a9_; }
798 template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); }
800 template<class T> T const & operator[] (_bi::value<T> const & v) const { return v.get(); }
802 template<class T> T & operator[] (reference_wrapper<T> const & v) const { return v.get(); }
804 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); }
806 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); }
808 template<class R, class F, class A> R operator()(type<R>, F & f, A & a, long)
810 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_]);
813 template<class R, class F, class A> R operator()(type<R>, F const & f, A & a, long) const
815 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_]);
818 template<class F, class A> void operator()(type<void>, F & f, A & a, int)
820 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_]);
823 template<class F, class A> void operator()(type<void>, F const & f, A & a, int) const
825 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_]);
828 template<class V> void accept(V & v) const
830 base_type::accept(v);
833 bool operator==(list9 const & rhs) const
835 return
837 ref_compare( base_type::a1_, rhs.a1_, 0 ) &&
838 ref_compare( base_type::a2_, rhs.a2_, 0 ) &&
839 ref_compare( base_type::a3_, rhs.a3_, 0 ) &&
840 ref_compare( base_type::a4_, rhs.a4_, 0 ) &&
841 ref_compare( base_type::a5_, rhs.a5_, 0 ) &&
842 ref_compare( base_type::a6_, rhs.a6_, 0 ) &&
843 ref_compare( base_type::a7_, rhs.a7_, 0 ) &&
844 ref_compare( base_type::a8_, rhs.a8_, 0 ) &&
845 ref_compare( base_type::a9_, rhs.a9_, 0 );
849 // bind_t
851 #ifndef BOOST_NO_VOID_RETURNS
853 template<class R, class F, class L> class bind_t
855 public:
857 typedef bind_t this_type;
859 bind_t(F f, L const & l): f_(f), l_(l) {}
861 #define BOOST_BIND_RETURN return
862 #include <boost/bind/bind_template.hpp>
863 #undef BOOST_BIND_RETURN
867 #else
869 template<class R> struct bind_t_generator
872 template<class F, class L> class implementation
874 public:
876 typedef implementation this_type;
878 implementation(F f, L const & l): f_(f), l_(l) {}
880 #define BOOST_BIND_RETURN return
881 #include <boost/bind/bind_template.hpp>
882 #undef BOOST_BIND_RETURN
888 template<> struct bind_t_generator<void>
891 template<class F, class L> class implementation
893 private:
895 typedef void R;
897 public:
899 typedef implementation this_type;
901 implementation(F f, L const & l): f_(f), l_(l) {}
903 #define BOOST_BIND_RETURN
904 #include <boost/bind/bind_template.hpp>
905 #undef BOOST_BIND_RETURN
911 template<class R2, class F, class L> class bind_t: public bind_t_generator<R2>::BOOST_NESTED_TEMPLATE implementation<F, L>
913 public:
915 bind_t(F f, L const & l): bind_t_generator<R2>::BOOST_NESTED_TEMPLATE implementation<F, L>(f, l) {}
919 #endif
921 // function_equal
923 #ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
925 // put overloads in _bi, rely on ADL
927 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
929 template<class R, class F, class L> bool function_equal( bind_t<R, F, L> const & a, bind_t<R, F, L> const & b )
931 return a.compare(b);
934 # else
936 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 )
938 return a.compare(b);
941 # endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
943 #else // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
945 // put overloads in boost
947 } // namespace _bi
949 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
951 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 )
953 return a.compare(b);
956 # else
958 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 )
960 return a.compare(b);
963 # endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
965 namespace _bi
968 #endif // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
970 // add_value
972 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530)
974 #if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x582) )
976 template<class T> struct add_value
978 typedef _bi::value<T> type;
981 #else
983 template< class T, int I > struct add_value_2
985 typedef boost::arg<I> type;
988 template< class T > struct add_value_2< T, 0 >
990 typedef _bi::value< T > type;
993 template<class T> struct add_value
995 typedef typename add_value_2< T, boost::is_placeholder< T >::value >::type type;
998 #endif
1000 template<class T> struct add_value< value<T> >
1002 typedef _bi::value<T> type;
1005 template<class T> struct add_value< reference_wrapper<T> >
1007 typedef reference_wrapper<T> type;
1010 template<int I> struct add_value< arg<I> >
1012 typedef boost::arg<I> type;
1015 template<int I> struct add_value< arg<I> (*) () >
1017 typedef boost::arg<I> (*type) ();
1020 template<class R, class F, class L> struct add_value< bind_t<R, F, L> >
1022 typedef bind_t<R, F, L> type;
1025 #else
1027 template<int I> struct _avt_0;
1029 template<> struct _avt_0<1>
1031 template<class T> struct inner
1033 typedef T type;
1037 template<> struct _avt_0<2>
1039 template<class T> struct inner
1041 typedef value<T> type;
1045 typedef char (&_avt_r1) [1];
1046 typedef char (&_avt_r2) [2];
1048 template<class T> _avt_r1 _avt_f(value<T>);
1049 template<class T> _avt_r1 _avt_f(reference_wrapper<T>);
1050 template<int I> _avt_r1 _avt_f(arg<I>);
1051 template<int I> _avt_r1 _avt_f(arg<I> (*) ());
1052 template<class R, class F, class L> _avt_r1 _avt_f(bind_t<R, F, L>);
1054 _avt_r2 _avt_f(...);
1056 template<class T> struct add_value
1058 static T t();
1059 typedef typename _avt_0<sizeof(_avt_f(t()))>::template inner<T>::type type;
1062 #endif
1064 // list_av_N
1066 template<class A1> struct list_av_1
1068 typedef typename add_value<A1>::type B1;
1069 typedef list1<B1> type;
1072 template<class A1, class A2> struct list_av_2
1074 typedef typename add_value<A1>::type B1;
1075 typedef typename add_value<A2>::type B2;
1076 typedef list2<B1, B2> type;
1079 template<class A1, class A2, class A3> struct list_av_3
1081 typedef typename add_value<A1>::type B1;
1082 typedef typename add_value<A2>::type B2;
1083 typedef typename add_value<A3>::type B3;
1084 typedef list3<B1, B2, B3> type;
1087 template<class A1, class A2, class A3, class A4> struct list_av_4
1089 typedef typename add_value<A1>::type B1;
1090 typedef typename add_value<A2>::type B2;
1091 typedef typename add_value<A3>::type B3;
1092 typedef typename add_value<A4>::type B4;
1093 typedef list4<B1, B2, B3, B4> type;
1096 template<class A1, class A2, class A3, class A4, class A5> struct list_av_5
1098 typedef typename add_value<A1>::type B1;
1099 typedef typename add_value<A2>::type B2;
1100 typedef typename add_value<A3>::type B3;
1101 typedef typename add_value<A4>::type B4;
1102 typedef typename add_value<A5>::type B5;
1103 typedef list5<B1, B2, B3, B4, B5> type;
1106 template<class A1, class A2, class A3, class A4, class A5, class A6> struct list_av_6
1108 typedef typename add_value<A1>::type B1;
1109 typedef typename add_value<A2>::type B2;
1110 typedef typename add_value<A3>::type B3;
1111 typedef typename add_value<A4>::type B4;
1112 typedef typename add_value<A5>::type B5;
1113 typedef typename add_value<A6>::type B6;
1114 typedef list6<B1, B2, B3, B4, B5, B6> type;
1117 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct list_av_7
1119 typedef typename add_value<A1>::type B1;
1120 typedef typename add_value<A2>::type B2;
1121 typedef typename add_value<A3>::type B3;
1122 typedef typename add_value<A4>::type B4;
1123 typedef typename add_value<A5>::type B5;
1124 typedef typename add_value<A6>::type B6;
1125 typedef typename add_value<A7>::type B7;
1126 typedef list7<B1, B2, B3, B4, B5, B6, B7> type;
1129 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct list_av_8
1131 typedef typename add_value<A1>::type B1;
1132 typedef typename add_value<A2>::type B2;
1133 typedef typename add_value<A3>::type B3;
1134 typedef typename add_value<A4>::type B4;
1135 typedef typename add_value<A5>::type B5;
1136 typedef typename add_value<A6>::type B6;
1137 typedef typename add_value<A7>::type B7;
1138 typedef typename add_value<A8>::type B8;
1139 typedef list8<B1, B2, B3, B4, B5, B6, B7, B8> type;
1142 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> struct list_av_9
1144 typedef typename add_value<A1>::type B1;
1145 typedef typename add_value<A2>::type B2;
1146 typedef typename add_value<A3>::type B3;
1147 typedef typename add_value<A4>::type B4;
1148 typedef typename add_value<A5>::type B5;
1149 typedef typename add_value<A6>::type B6;
1150 typedef typename add_value<A7>::type B7;
1151 typedef typename add_value<A8>::type B8;
1152 typedef typename add_value<A9>::type B9;
1153 typedef list9<B1, B2, B3, B4, B5, B6, B7, B8, B9> type;
1156 // operator!
1158 struct logical_not
1160 template<class V> bool operator()(V const & v) const { return !v; }
1163 template<class R, class F, class L>
1164 bind_t< bool, logical_not, list1< bind_t<R, F, L> > >
1165 operator! (bind_t<R, F, L> const & f)
1167 typedef list1< bind_t<R, F, L> > list_type;
1168 return bind_t<bool, logical_not, list_type> ( logical_not(), list_type(f) );
1171 // relational operators
1173 #define BOOST_BIND_OPERATOR( op, name ) \
1175 struct name \
1177 template<class V, class W> bool operator()(V const & v, W const & w) const { return v op w; } \
1178 }; \
1180 template<class R, class F, class L, class A2> \
1181 bind_t< bool, name, list2< bind_t<R, F, L>, typename add_value<A2>::type > > \
1182 operator op (bind_t<R, F, L> const & f, A2 a2) \
1184 typedef typename add_value<A2>::type B2; \
1185 typedef list2< bind_t<R, F, L>, B2> list_type; \
1186 return bind_t<bool, name, list_type> ( name(), list_type(f, a2) ); \
1189 BOOST_BIND_OPERATOR( ==, equal )
1190 BOOST_BIND_OPERATOR( !=, not_equal )
1192 BOOST_BIND_OPERATOR( <, less )
1193 BOOST_BIND_OPERATOR( <=, less_equal )
1195 BOOST_BIND_OPERATOR( >, greater )
1196 BOOST_BIND_OPERATOR( >=, greater_equal )
1198 BOOST_BIND_OPERATOR( &&, logical_and )
1199 BOOST_BIND_OPERATOR( ||, logical_or )
1201 #undef BOOST_BIND_OPERATOR
1203 #if defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3)
1205 // resolve ambiguity with rel_ops
1207 #define BOOST_BIND_OPERATOR( op, name ) \
1209 template<class R, class F, class L> \
1210 bind_t< bool, name, list2< bind_t<R, F, L>, bind_t<R, F, L> > > \
1211 operator op (bind_t<R, F, L> const & f, bind_t<R, F, L> const & g) \
1213 typedef list2< bind_t<R, F, L>, bind_t<R, F, L> > list_type; \
1214 return bind_t<bool, name, list_type> ( name(), list_type(f, g) ); \
1217 BOOST_BIND_OPERATOR( !=, not_equal )
1218 BOOST_BIND_OPERATOR( <=, less_equal )
1219 BOOST_BIND_OPERATOR( >, greater )
1220 BOOST_BIND_OPERATOR( >=, greater_equal )
1222 #endif
1224 // visit_each, ADL
1226 #if !defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) && !defined( __BORLANDC__ ) \
1227 && !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
1229 template<class V, class T> void visit_each( V & v, value<T> const & t, int )
1231 using boost::visit_each;
1232 BOOST_BIND_VISIT_EACH( v, t.get(), 0 );
1235 template<class V, class R, class F, class L> void visit_each( V & v, bind_t<R, F, L> const & t, int )
1237 t.accept( v );
1240 #endif
1242 } // namespace _bi
1244 // visit_each, no ADL
1246 #if defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) || defined( __BORLANDC__ ) \
1247 || (defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
1249 template<class V, class T> void visit_each( V & v, _bi::value<T> const & t, int )
1251 BOOST_BIND_VISIT_EACH( v, t.get(), 0 );
1254 template<class V, class R, class F, class L> void visit_each( V & v, _bi::bind_t<R, F, L> const & t, int )
1256 t.accept( v );
1259 #endif
1261 // is_bind_expression
1263 template< class T > struct is_bind_expression
1265 enum _vt { value = 0 };
1268 #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
1270 template< class R, class F, class L > struct is_bind_expression< _bi::bind_t< R, F, L > >
1272 enum _vt { value = 1 };
1275 #endif
1277 // bind
1279 #ifndef BOOST_BIND
1280 #define BOOST_BIND bind
1281 #endif
1283 // generic function objects
1285 template<class R, class F>
1286 _bi::bind_t<R, F, _bi::list0>
1287 BOOST_BIND(F f)
1289 typedef _bi::list0 list_type;
1290 return _bi::bind_t<R, F, list_type> (f, list_type());
1293 template<class R, class F, class A1>
1294 _bi::bind_t<R, F, typename _bi::list_av_1<A1>::type>
1295 BOOST_BIND(F f, A1 a1)
1297 typedef typename _bi::list_av_1<A1>::type list_type;
1298 return _bi::bind_t<R, F, list_type> (f, list_type(a1));
1301 template<class R, class F, class A1, class A2>
1302 _bi::bind_t<R, F, typename _bi::list_av_2<A1, A2>::type>
1303 BOOST_BIND(F f, A1 a1, A2 a2)
1305 typedef typename _bi::list_av_2<A1, A2>::type list_type;
1306 return _bi::bind_t<R, F, list_type> (f, list_type(a1, a2));
1309 template<class R, class F, class A1, class A2, class A3>
1310 _bi::bind_t<R, F, typename _bi::list_av_3<A1, A2, A3>::type>
1311 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3)
1313 typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
1314 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3));
1317 template<class R, class F, class A1, class A2, class A3, class A4>
1318 _bi::bind_t<R, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
1319 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4)
1321 typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
1322 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4));
1325 template<class R, class F, class A1, class A2, class A3, class A4, class A5>
1326 _bi::bind_t<R, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
1327 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
1329 typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
1330 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
1333 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6>
1334 _bi::bind_t<R, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
1335 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
1337 typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
1338 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
1341 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
1342 _bi::bind_t<R, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
1343 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
1345 typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
1346 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
1349 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
1350 _bi::bind_t<R, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
1351 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
1353 typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
1354 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
1357 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
1358 _bi::bind_t<R, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
1359 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
1361 typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
1362 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
1365 // generic function objects, alternative syntax
1367 template<class R, class F>
1368 _bi::bind_t<R, F, _bi::list0>
1369 BOOST_BIND(boost::type<R>, F f)
1371 typedef _bi::list0 list_type;
1372 return _bi::bind_t<R, F, list_type> (f, list_type());
1375 template<class R, class F, class A1>
1376 _bi::bind_t<R, F, typename _bi::list_av_1<A1>::type>
1377 BOOST_BIND(boost::type<R>, F f, A1 a1)
1379 typedef typename _bi::list_av_1<A1>::type list_type;
1380 return _bi::bind_t<R, F, list_type> (f, list_type(a1));
1383 template<class R, class F, class A1, class A2>
1384 _bi::bind_t<R, F, typename _bi::list_av_2<A1, A2>::type>
1385 BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2)
1387 typedef typename _bi::list_av_2<A1, A2>::type list_type;
1388 return _bi::bind_t<R, F, list_type> (f, list_type(a1, a2));
1391 template<class R, class F, class A1, class A2, class A3>
1392 _bi::bind_t<R, F, typename _bi::list_av_3<A1, A2, A3>::type>
1393 BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3)
1395 typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
1396 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3));
1399 template<class R, class F, class A1, class A2, class A3, class A4>
1400 _bi::bind_t<R, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
1401 BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4)
1403 typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
1404 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4));
1407 template<class R, class F, class A1, class A2, class A3, class A4, class A5>
1408 _bi::bind_t<R, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
1409 BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
1411 typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
1412 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
1415 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6>
1416 _bi::bind_t<R, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
1417 BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
1419 typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
1420 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
1423 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
1424 _bi::bind_t<R, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
1425 BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
1427 typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
1428 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
1431 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
1432 _bi::bind_t<R, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
1433 BOOST_BIND(boost::type<R>, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
1435 typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
1436 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
1439 template<class R, class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
1440 _bi::bind_t<R, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
1441 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)
1443 typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
1444 return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
1447 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
1449 // adaptable function objects
1451 template<class F>
1452 _bi::bind_t<_bi::unspecified, F, _bi::list0>
1453 BOOST_BIND(F f)
1455 typedef _bi::list0 list_type;
1456 return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type());
1459 template<class F, class A1>
1460 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_1<A1>::type>
1461 BOOST_BIND(F f, A1 a1)
1463 typedef typename _bi::list_av_1<A1>::type list_type;
1464 return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type(a1));
1467 template<class F, class A1, class A2>
1468 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_2<A1, A2>::type>
1469 BOOST_BIND(F f, A1 a1, A2 a2)
1471 typedef typename _bi::list_av_2<A1, A2>::type list_type;
1472 return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type(a1, a2));
1475 template<class F, class A1, class A2, class A3>
1476 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_3<A1, A2, A3>::type>
1477 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3)
1479 typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
1480 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3));
1483 template<class F, class A1, class A2, class A3, class A4>
1484 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_4<A1, A2, A3, A4>::type>
1485 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4)
1487 typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
1488 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4));
1491 template<class F, class A1, class A2, class A3, class A4, class A5>
1492 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
1493 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
1495 typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
1496 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
1499 template<class F, class A1, class A2, class A3, class A4, class A5, class A6>
1500 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
1501 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
1503 typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
1504 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
1507 template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
1508 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
1509 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
1511 typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
1512 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
1515 template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
1516 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
1517 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
1519 typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
1520 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
1523 template<class F, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
1524 _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
1525 BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
1527 typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
1528 return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
1531 #endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
1533 // function pointers
1535 #define BOOST_BIND_CC
1536 #define BOOST_BIND_ST
1538 #include <boost/bind/bind_cc.hpp>
1540 #undef BOOST_BIND_CC
1541 #undef BOOST_BIND_ST
1543 #ifdef BOOST_BIND_ENABLE_STDCALL
1545 #define BOOST_BIND_CC __stdcall
1546 #define BOOST_BIND_ST
1548 #include <boost/bind/bind_cc.hpp>
1550 #undef BOOST_BIND_CC
1551 #undef BOOST_BIND_ST
1553 #endif
1555 #ifdef BOOST_BIND_ENABLE_FASTCALL
1557 #define BOOST_BIND_CC __fastcall
1558 #define BOOST_BIND_ST
1560 #include <boost/bind/bind_cc.hpp>
1562 #undef BOOST_BIND_CC
1563 #undef BOOST_BIND_ST
1565 #endif
1567 #ifdef BOOST_BIND_ENABLE_PASCAL
1569 #define BOOST_BIND_ST pascal
1570 #define BOOST_BIND_CC
1572 #include <boost/bind/bind_cc.hpp>
1574 #undef BOOST_BIND_ST
1575 #undef BOOST_BIND_CC
1577 #endif
1579 // member function pointers
1581 #define BOOST_BIND_MF_NAME(X) X
1582 #define BOOST_BIND_MF_CC
1584 #include <boost/bind/bind_mf_cc.hpp>
1585 #include <boost/bind/bind_mf2_cc.hpp>
1587 #undef BOOST_BIND_MF_NAME
1588 #undef BOOST_BIND_MF_CC
1590 #ifdef BOOST_MEM_FN_ENABLE_CDECL
1592 #define BOOST_BIND_MF_NAME(X) X##_cdecl
1593 #define BOOST_BIND_MF_CC __cdecl
1595 #include <boost/bind/bind_mf_cc.hpp>
1596 #include <boost/bind/bind_mf2_cc.hpp>
1598 #undef BOOST_BIND_MF_NAME
1599 #undef BOOST_BIND_MF_CC
1601 #endif
1603 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
1605 #define BOOST_BIND_MF_NAME(X) X##_stdcall
1606 #define BOOST_BIND_MF_CC __stdcall
1608 #include <boost/bind/bind_mf_cc.hpp>
1609 #include <boost/bind/bind_mf2_cc.hpp>
1611 #undef BOOST_BIND_MF_NAME
1612 #undef BOOST_BIND_MF_CC
1614 #endif
1616 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
1618 #define BOOST_BIND_MF_NAME(X) X##_fastcall
1619 #define BOOST_BIND_MF_CC __fastcall
1621 #include <boost/bind/bind_mf_cc.hpp>
1622 #include <boost/bind/bind_mf2_cc.hpp>
1624 #undef BOOST_BIND_MF_NAME
1625 #undef BOOST_BIND_MF_CC
1627 #endif
1629 // data member pointers
1631 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
1632 || ( defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, <= 0x610 ) )
1634 template<class R, class T, class A1>
1635 _bi::bind_t< R, _mfi::dm<R, T>, typename _bi::list_av_1<A1>::type >
1636 BOOST_BIND(R T::*f, A1 a1)
1638 typedef _mfi::dm<R, T> F;
1639 typedef typename _bi::list_av_1<A1>::type list_type;
1640 return _bi::bind_t<R, F, list_type>( F(f), list_type(a1) );
1643 #else
1645 namespace _bi
1648 template< class Pm, int I > struct add_cref;
1650 template< class M, class T > struct add_cref< M T::*, 0 >
1652 typedef M type;
1655 template< class M, class T > struct add_cref< M T::*, 1 >
1657 typedef M const & type;
1660 template< class R, class T > struct add_cref< R (T::*) (), 1 >
1662 typedef void type;
1665 #if !( defined(__IBMCPP__) && BOOST_WORKAROUND( __IBMCPP__, BOOST_TESTED_AT(600) ) )
1667 template< class R, class T > struct add_cref< R (T::*) () const, 1 >
1669 typedef void type;
1672 #endif // __IBMCPP__
1674 template<class R> struct isref
1676 enum value_type { value = 0 };
1679 template<class R> struct isref< R& >
1681 enum value_type { value = 1 };
1684 template<class R> struct isref< R* >
1686 enum value_type { value = 1 };
1689 template<class Pm, class A1> struct dm_result
1691 typedef typename add_cref< Pm, 1 >::type type;
1694 template<class Pm, class R, class F, class L> struct dm_result< Pm, bind_t<R, F, L> >
1696 typedef typename bind_t<R, F, L>::result_type result_type;
1697 typedef typename add_cref< Pm, isref< result_type >::value >::type type;
1700 } // namespace _bi
1702 template< class A1, class M, class T >
1704 _bi::bind_t<
1705 typename _bi::dm_result< M T::*, A1 >::type,
1706 _mfi::dm<M, T>,
1707 typename _bi::list_av_1<A1>::type
1710 BOOST_BIND( M T::*f, A1 a1 )
1712 typedef typename _bi::dm_result< M T::*, A1 >::type result_type;
1713 typedef _mfi::dm<M, T> F;
1714 typedef typename _bi::list_av_1<A1>::type list_type;
1715 return _bi::bind_t< result_type, F, list_type >( F( f ), list_type( a1 ) );
1718 #endif
1720 } // namespace boost
1722 #ifndef BOOST_BIND_NO_PLACEHOLDERS
1724 # include <boost/bind/placeholders.hpp>
1726 #endif
1728 #ifdef BOOST_MSVC
1729 # pragma warning(default: 4512) // assignment operator could not be generated
1730 # pragma warning(pop)
1731 #endif
1733 #endif // #ifndef BOOST_BIND_BIND_HPP_INCLUDED