]> git.lyx.org Git - lyx.git/blob - boost/boost/function.hpp
update from Boost CVS
[lyx.git] / boost / boost / function.hpp
1 // Boost.Function library
2
3 // Copyright (C) 2001, 2002 Doug Gregor (gregod@cs.rpi.edu)
4 //
5 // Permission to copy, use, sell and distribute this software is granted
6 // provided this copyright notice appears in all copies.
7 // Permission to modify the code and to distribute modified code is granted
8 // provided this copyright notice appears in all copies, and a notice
9 // that the code was modified is included with the copyright notice.
10 //
11 // This software is provided "as is" without express or implied warranty,
12 // and with no claim as to its suitability for any purpose.
13  
14 // For more information, see http://www.boost.org
15  
16 // William Kempf, Jesse Jones and Karl Nelson were all very helpful in the
17 // design of this library.
18
19 #ifndef BOOST_FUNCTION_HPP
20 #define BOOST_FUNCTION_HPP
21
22 #include <boost/function/function_base.hpp>
23 #include <boost/type_traits/function_traits.hpp>
24 #include <boost/type_traits/same_traits.hpp>
25 #include <boost/type_traits/transform_traits.hpp>
26 #include <boost/type_traits/ice.hpp>
27 #include <boost/function/function0.hpp>
28 #include <boost/function/function1.hpp>
29 #include <boost/function/function2.hpp>
30 #include <boost/function/function3.hpp>
31 #include <boost/function/function4.hpp>
32 #include <boost/function/function5.hpp>
33 #include <boost/function/function6.hpp>
34 #include <boost/function/function7.hpp>
35 #include <boost/function/function8.hpp>
36 #include <boost/function/function9.hpp>
37 #include <boost/function/function10.hpp>
38
39 // Don't compile any of this code if we've asked not to include the deprecated
40 // syntax and we don't have partial specialization, because none of this code
41 // can work.
42 #if !defined (BOOST_FUNCTION_NO_DEPRECATED) || !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
43
44 namespace boost {
45   namespace detail {
46     namespace function {
47       // Choose the appropriate underlying implementation
48       template<int Args> struct real_get_function_impl {};
49
50       template<>
51       struct real_get_function_impl<0>
52       {
53         template<
54           typename R, 
55           typename T1,
56           typename T2,
57           typename T3,
58           typename T4,
59           typename T5,
60           typename T6,
61           typename T7,
62           typename T8,
63           typename T9,
64           typename T10,
65 #ifndef BOOST_FUNCTION_NO_DEPRECATED
66           typename Policy,
67           typename Mixin,
68 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
69           typename Allocator
70         >
71         struct params
72         {
73           typedef function0<R, 
74 #ifndef BOOST_FUNCTION_NO_DEPRECATED
75                             Policy, Mixin, 
76 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
77                             Allocator> type;
78         };
79       };
80
81       template<>
82       struct real_get_function_impl<1>
83       {
84         template<
85           typename R, 
86           typename T1,
87           typename T2,
88           typename T3,
89           typename T4,
90           typename T5,
91           typename T6,
92           typename T7,
93           typename T8,
94           typename T9,
95           typename T10,
96 #ifndef BOOST_FUNCTION_NO_DEPRECATED
97           typename Policy,
98           typename Mixin,
99 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
100           typename Allocator
101         >
102         struct params
103         {
104           typedef function1<R, T1, 
105 #ifndef BOOST_FUNCTION_NO_DEPRECATED
106                             Policy, Mixin, 
107 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
108                             Allocator> type;
109         };
110       };
111
112       template<>
113       struct real_get_function_impl<2>
114       {
115         template<
116           typename R, 
117           typename T1,
118           typename T2,
119           typename T3,
120           typename T4,
121           typename T5,
122           typename T6,
123           typename T7,
124           typename T8,
125           typename T9,
126           typename T10,
127 #ifndef BOOST_FUNCTION_NO_DEPRECATED
128           typename Policy,
129           typename Mixin,
130 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
131           typename Allocator
132         >
133         struct params
134         {
135           typedef function2<R, T1, T2, 
136 #ifndef BOOST_FUNCTION_NO_DEPRECATED
137                             Policy, Mixin, 
138 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
139                             Allocator> type;
140         };
141       };
142
143       template<>
144       struct real_get_function_impl<3>
145       {
146         template<
147           typename R, 
148           typename T1,
149           typename T2,
150           typename T3,
151           typename T4,
152           typename T5,
153           typename T6,
154           typename T7,
155           typename T8,
156           typename T9,
157           typename T10,
158 #ifndef BOOST_FUNCTION_NO_DEPRECATED
159           typename Policy,
160           typename Mixin,
161 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
162           typename Allocator
163         >
164         struct params
165         {
166           typedef function3<R, T1, T2, T3, 
167 #ifndef BOOST_FUNCTION_NO_DEPRECATED
168                             Policy, Mixin, 
169 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
170                             Allocator> type;
171         };
172       };
173
174       template<>
175       struct real_get_function_impl<4>
176       {
177         template<
178           typename R, 
179           typename T1,
180           typename T2,
181           typename T3,
182           typename T4,
183           typename T5,
184           typename T6,
185           typename T7,
186           typename T8,
187           typename T9,
188           typename T10,
189 #ifndef BOOST_FUNCTION_NO_DEPRECATED
190           typename Policy,
191           typename Mixin,
192 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
193           typename Allocator
194         >
195         struct params
196         {
197           typedef function4<R, T1, T2, T3, T4, 
198 #ifndef BOOST_FUNCTION_NO_DEPRECATED
199                             Policy, Mixin, 
200 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
201                             Allocator> type;
202         };
203       };
204
205       template<>
206       struct real_get_function_impl<5>
207       {
208         template<
209           typename R, 
210           typename T1,
211           typename T2,
212           typename T3,
213           typename T4,
214           typename T5,
215           typename T6,
216           typename T7,
217           typename T8,
218           typename T9,
219           typename T10,
220 #ifndef BOOST_FUNCTION_NO_DEPRECATED
221           typename Policy,
222           typename Mixin,
223 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
224           typename Allocator
225         >
226         struct params
227         {
228           typedef function5<R, T1, T2, T3, T4, T5, 
229 #ifndef BOOST_FUNCTION_NO_DEPRECATED
230                             Policy, Mixin, 
231 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
232                             Allocator> 
233           type;
234         };
235       };
236
237       template<>
238       struct real_get_function_impl<6>
239       {
240         template<
241           typename R, 
242           typename T1,
243           typename T2,
244           typename T3,
245           typename T4,
246           typename T5,
247           typename T6,
248           typename T7,
249           typename T8,
250           typename T9,
251           typename T10,
252 #ifndef BOOST_FUNCTION_NO_DEPRECATED
253           typename Policy,
254           typename Mixin,
255 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
256           typename Allocator
257         >
258         struct params
259         {
260           typedef function6<R, T1, T2, T3, T4, T5, T6, 
261 #ifndef BOOST_FUNCTION_NO_DEPRECATED
262                             Policy, Mixin, 
263 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
264                             Allocator>
265           type;
266         };
267       };
268
269       template<>
270       struct real_get_function_impl<7>
271       {
272         template<
273           typename R, 
274           typename T1,
275           typename T2,
276           typename T3,
277           typename T4,
278           typename T5,
279           typename T6,
280           typename T7,
281           typename T8,
282           typename T9,
283           typename T10,
284 #ifndef BOOST_FUNCTION_NO_DEPRECATED
285           typename Policy,
286           typename Mixin,
287 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
288           typename Allocator
289         >
290         struct params
291         {
292           typedef function7<R, T1, T2, T3, T4, T5, T6, T7, 
293 #ifndef BOOST_FUNCTION_NO_DEPRECATED
294                             Policy, Mixin, 
295 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
296                             Allocator> type;
297         };
298       };
299
300       template<>
301       struct real_get_function_impl<8>
302       {
303         template<
304           typename R, 
305           typename T1,
306           typename T2,
307           typename T3,
308           typename T4,
309           typename T5,
310           typename T6,
311           typename T7,
312           typename T8,
313           typename T9,
314           typename T10,
315 #ifndef BOOST_FUNCTION_NO_DEPRECATED
316           typename Policy,
317           typename Mixin,
318 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
319           typename Allocator
320         >
321         struct params
322         {
323           typedef function8<R, T1, T2, T3, T4, T5, T6, T7, T8, 
324 #ifndef BOOST_FUNCTION_NO_DEPRECATED
325                             Policy, Mixin, 
326 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
327                             Allocator> type;
328         };
329       };
330
331       template<>
332       struct real_get_function_impl<9>
333       {
334         template<
335           typename R, 
336           typename T1,
337           typename T2,
338           typename T3,
339           typename T4,
340           typename T5,
341           typename T6,
342           typename T7,
343           typename T8,
344           typename T9,
345           typename T10,
346 #ifndef BOOST_FUNCTION_NO_DEPRECATED
347           typename Policy,
348           typename Mixin,
349 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
350           typename Allocator
351         >
352         struct params
353         {
354           typedef function9<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, 
355 #ifndef BOOST_FUNCTION_NO_DEPRECATED
356                             Policy, Mixin, 
357 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
358                             Allocator> type;
359         };
360       };
361
362       template<>
363       struct real_get_function_impl<10>
364       {
365         template<
366           typename R, 
367           typename T1,
368           typename T2,
369           typename T3,
370           typename T4,
371           typename T5,
372           typename T6,
373           typename T7,
374           typename T8,
375           typename T9,
376           typename T10,
377 #ifndef BOOST_FUNCTION_NO_DEPRECATED
378           typename Policy,
379           typename Mixin,
380 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
381           typename Allocator
382         >
383         struct params
384         {
385           typedef function10<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, 
386 #ifndef BOOST_FUNCTION_NO_DEPRECATED
387                              Policy, Mixin, 
388 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
389                              Allocator> type;
390         };
391       };
392
393 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
394       template<bool GetIt, typename Traits> 
395       struct get_arg1_type
396       {
397         typedef unusable type;
398       };
399
400       template<typename Traits> 
401       struct get_arg1_type<true, Traits>
402       {
403         typedef typename Traits::arg1_type type;
404       };
405
406       template<bool GetIt, typename Traits> 
407       struct get_arg2_type
408       {
409         typedef unusable type;
410       };
411
412       template<typename Traits> 
413       struct get_arg2_type<true, Traits>
414       {
415         typedef typename Traits::arg2_type type;
416       };
417
418       template<bool GetIt, typename Traits> 
419       struct get_arg3_type
420       {
421         typedef unusable type;
422       };
423
424       template<typename Traits> 
425       struct get_arg3_type<true, Traits>
426       {
427         typedef typename Traits::arg3_type type;
428       };
429
430       template<bool GetIt, typename Traits> 
431       struct get_arg4_type
432       {
433         typedef unusable type;
434       };
435
436       template<typename Traits> 
437       struct get_arg4_type<true, Traits>
438       {
439         typedef typename Traits::arg4_type type;
440       };
441
442       template<bool GetIt, typename Traits> 
443       struct get_arg5_type
444       {
445         typedef unusable type;
446       };
447
448       template<typename Traits> 
449       struct get_arg5_type<true, Traits>
450       {
451         typedef typename Traits::arg5_type type;
452       };
453
454       template<bool GetIt, typename Traits> 
455       struct get_arg6_type
456       {
457         typedef unusable type;
458       };
459
460       template<typename Traits> 
461       struct get_arg6_type<true, Traits>
462       {
463         typedef typename Traits::arg6_type type;
464       };
465
466       template<bool GetIt, typename Traits> 
467       struct get_arg7_type
468       {
469         typedef unusable type;
470       };
471
472       template<typename Traits> 
473       struct get_arg7_type<true, Traits>
474       {
475         typedef typename Traits::arg7_type type;
476       };
477
478       template<bool GetIt, typename Traits> 
479       struct get_arg8_type
480       {
481         typedef unusable type;
482       };
483
484       template<typename Traits> 
485       struct get_arg8_type<true, Traits>
486       {
487         typedef typename Traits::arg8_type type;
488         };
489
490       template<bool GetIt, typename Traits> 
491       struct get_arg9_type
492       {
493         typedef unusable type;
494       };
495
496       template<typename Traits> 
497       struct get_arg9_type<true, Traits>
498       {
499         typedef typename Traits::arg9_type type;
500       };
501
502       template<bool GetIt, typename Traits> 
503       struct get_arg10_type
504       {
505         typedef unusable type;
506       };
507
508       template<typename Traits> 
509       struct get_arg10_type<true, Traits>
510       {
511         typedef typename Traits::arg10_type type;
512       };
513
514       template<int X, int Y> 
515       struct gte
516       {
517         BOOST_STATIC_CONSTANT(bool, value = (X >= Y));
518       };
519
520       template<bool IsFunction,
521                typename InR, 
522                typename InT1, 
523                typename InT2, 
524                typename InT3, 
525                typename InT4,
526                typename InT5, 
527                typename InT6, 
528                typename InT7, 
529                typename InT8, 
530                typename InT9,
531                typename InT10,
532 #ifndef BOOST_FUNCTION_NO_DEPRECATED
533                typename InPolicy,
534                typename InMixin,
535 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
536                typename InAllocator>
537       struct maybe_decode_function_args
538       {
539         typedef function_traits<InR> traits;
540
541         typedef typename traits::result_type R;
542         typedef typename get_arg1_type<(gte<(traits::arity), 1>::value), 
543                                        traits>::type T1;
544         typedef typename get_arg2_type<(gte<(traits::arity), 2>::value), 
545                                        traits>::type T2;
546         typedef typename get_arg3_type<(gte<(traits::arity), 3>::value), 
547                                        traits>::type T3;
548         typedef typename get_arg4_type<(gte<(traits::arity), 4>::value), 
549                                        traits>::type T4;
550         typedef typename get_arg5_type<(gte<(traits::arity), 5>::value), 
551                                        traits>::type T5;
552         typedef typename get_arg6_type<(gte<(traits::arity), 6>::value), 
553                                        traits>::type T6;
554         typedef typename get_arg7_type<(gte<(traits::arity), 7>::value), 
555                                        traits>::type T7;
556         typedef typename get_arg8_type<(gte<(traits::arity), 8>::value), 
557                                        traits>::type T8;
558         typedef typename get_arg9_type<(gte<(traits::arity), 9>::value), 
559                                        traits>::type T9;
560         typedef typename get_arg10_type<(gte<(traits::arity), 10>::value), 
561                                         traits>::type T10;
562
563 #ifndef BOOST_FUNCTION_NO_DEPRECATED
564         typedef typename ct_if<(is_same<InT1, unusable>::value),
565                                empty_function_policy,
566                                InT1>::type Policy;
567         typedef typename ct_if<(is_same<InT2, unusable>::value),
568                                empty_function_mixin,
569                                InT2>::type Mixin;
570         typedef typename ct_if<(is_same<InT3, unusable>::value),
571                                std::allocator<function_base>,
572                                InT3>::type Allocator;
573 #else
574         typedef typename ct_if<(is_same<InT1, unusable>::value),
575                                std::allocator<function_base>,
576                                InT1>::type Allocator;
577 #endif // BOOST_FUNCTION_NO_DEPRECATED
578       };
579
580 #ifndef BOOST_FUNCTION_NO_DEPRECATED
581       template<typename InR, 
582                typename InT1, 
583                typename InT2, 
584                typename InT3, 
585                typename InT4,
586                typename InT5, 
587                typename InT6, 
588                typename InT7, 
589                typename InT8, 
590                typename InT9,
591                typename InT10,
592 #ifndef BOOST_FUNCTION_NO_DEPRECATED
593                typename InPolicy,
594                typename InMixin,
595 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
596                typename InAllocator>
597       struct maybe_decode_function_args<false, InR, InT1, InT2, InT3, InT4,
598                                         InT5, InT6, InT7, InT8, InT9, InT10,
599 #ifndef BOOST_FUNCTION_NO_DEPRECATED
600                                         InPolicy, InMixin,
601 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED 
602                                         InAllocator>
603       {
604         // Not a function, so just map the types directly
605         typedef InR R;
606         typedef InT1 T1;
607         typedef InT2 T2;
608         typedef InT3 T3;
609         typedef InT4 T4;
610         typedef InT5 T5;
611         typedef InT6 T6;
612         typedef InT7 T7;
613         typedef InT8 T8;
614         typedef InT9 T9;
615         typedef InT10 T10;
616 #ifndef BOOST_FUNCTION_NO_DEPRECATED
617         typedef InPolicy Policy;
618         typedef InMixin Mixin;
619 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
620         typedef InAllocator Allocator;
621
622       };
623 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
624
625 #endif // ndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
626
627       template<
628         typename InR, 
629         typename InT1, 
630         typename InT2, 
631         typename InT3, 
632         typename InT4,
633         typename InT5, 
634         typename InT6, 
635         typename InT7, 
636         typename InT8, 
637         typename InT9,
638         typename InT10,
639         typename InPolicy = empty_function_policy,
640         typename InMixin = empty_function_mixin,
641         typename InAllocator = std::allocator<function_base> 
642       >
643       struct get_function_impl
644       {
645 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
646         typedef maybe_decode_function_args<(is_function<InR>::value),
647                                            InR, InT1, InT2, InT3, InT4, InT5,
648                                            InT6, InT7, InT8, InT9, InT10,
649 #ifndef BOOST_FUNCTION_NO_DEPRECATED
650                                            InPolicy, InMixin, 
651 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
652                                            InAllocator> decoder;
653         typedef typename decoder::R R;
654         typedef typename decoder::T1 T1;
655         typedef typename decoder::T2 T2;
656         typedef typename decoder::T3 T3;
657         typedef typename decoder::T4 T4;
658         typedef typename decoder::T5 T5;
659         typedef typename decoder::T6 T6;
660         typedef typename decoder::T7 T7;
661         typedef typename decoder::T8 T8;
662         typedef typename decoder::T9 T9;
663         typedef typename decoder::T10 T10;
664 #ifndef BOOST_FUNCTION_NO_DEPRECATED
665         typedef typename decoder::Policy Policy;
666         typedef typename decoder::Mixin Mixin;
667 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
668         typedef typename decoder::Allocator Allocator;
669 #else
670                 typedef InR R;
671                 typedef InT1 T1;
672                 typedef InT2 T2;
673                 typedef InT3 T3;
674                 typedef InT4 T4;
675                 typedef InT5 T5;
676                 typedef InT6 T6;
677                 typedef InT7 T7;
678                 typedef InT8 T8;
679                 typedef InT9 T9;
680                 typedef InT10 T10;
681                 typedef InPolicy Policy;
682                 typedef InMixin Mixin;
683                 typedef InAllocator Allocator;
684 #endif // def BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
685
686         typedef typename real_get_function_impl<
687           (count_used_args<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>::value)
688           >::template params<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, 
689 #ifndef BOOST_FUNCTION_NO_DEPRECATED
690                              Policy, Mixin, 
691 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
692                              Allocator>::type
693         type;
694       };
695
696 #ifndef BOOST_FUNCTION_NO_DEPRECATED
697   template<
698     typename InR, 
699     typename InT1, 
700     typename InT2, 
701     typename InT3, 
702     typename InT4,
703     typename InT5, 
704     typename InT6, 
705     typename InT7, 
706     typename InT8, 
707     typename InT9,
708     typename InT10,
709     typename InMyPolicy = empty_function_policy,
710     typename InMyMixin = empty_function_mixin,
711     typename InMyAllocator = std::allocator<function_base> 
712   >
713   class function_traits_builder
714   {
715     typedef get_function_impl<InR, InT1, InT2, InT3, InT4, InT5, InT6, InT7, 
716                               InT8, InT9, InT10, InMyPolicy, InMyMixin, 
717                               InMyAllocator>
718       impl;
719
720     typedef typename impl::R MyR;
721     typedef typename impl::T1 MyT1;
722     typedef typename impl::T2 MyT2;
723     typedef typename impl::T3 MyT3;
724     typedef typename impl::T4 MyT4;
725     typedef typename impl::T5 MyT5;
726     typedef typename impl::T6 MyT6;
727     typedef typename impl::T7 MyT7;
728     typedef typename impl::T8 MyT8;
729     typedef typename impl::T9 MyT9;
730     typedef typename impl::T10 MyT10;
731     typedef typename impl::Policy MyPolicy;
732     typedef typename impl::Mixin MyMixin;
733     typedef typename impl::Allocator MyAllocator;
734
735   public:
736     typedef typename impl::type type;
737     typedef MyPolicy    policy_type;
738     typedef MyMixin     mixin_type;
739     typedef MyAllocator allocator_type;
740
741 #ifndef BOOST_NO_DEPENDENT_NESTED_DERIVATIONS
742     template<typename Policy>
743     struct policy : 
744         public function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4, MyT5, MyT6,
745                                        MyT7, MyT8, MyT9, MyT10, Policy, 
746                                        mixin_type, allocator_type> {};
747
748     template<typename Mixin>
749     struct mixin : 
750         public function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4, MyT5, MyT6,
751                                        MyT7, MyT8, MyT9, MyT10, policy_type, 
752                                        Mixin, allocator_type> {};
753
754     template<typename Allocator>
755     struct allocator : 
756         public function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4, MyT5, MyT6,
757                                        MyT7, MyT8, MyT9, MyT10, policy_type, 
758                                        mixin_type, Allocator> {};
759 #else
760     template<typename Policy>
761     struct policy 
762     {
763       typedef typename function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4, 
764                                                MyT5, MyT6, MyT7, MyT8, MyT9, 
765                                                MyT10, Policy, mixin_type, 
766                                                allocator_type>::type
767         type;
768     };
769
770     template<typename Mixin>
771     struct mixin
772     {
773       typedef typename function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4, 
774                                                MyT5, MyT6, MyT7, MyT8, MyT9, 
775                                                MyT10, policy_type, Mixin,
776                                                allocator_type>::type
777         type;
778     };
779
780     template<typename Allocator>
781     struct allocator
782     {
783       typedef typename function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4, 
784                                                MyT5, MyT6, MyT7, MyT8, MyT9, 
785                                                MyT10, policy_type, mixin_type,
786                                                Allocator>::type
787         type;
788     };
789 #endif // ndef NO_DEPENDENT_NESTED_DERIVATIONS
790   };
791 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
792     } // end namespace function
793   } // end namespace detail
794
795   template<
796     typename R, 
797     typename T1 = detail::function::unusable, 
798     typename T2 = detail::function::unusable,
799     typename T3 = detail::function::unusable,
800     typename T4 = detail::function::unusable,
801     typename T5 = detail::function::unusable,
802     typename T6 = detail::function::unusable,
803     typename T7 = detail::function::unusable,
804     typename T8 = detail::function::unusable,
805     typename T9 = detail::function::unusable,
806     typename T10 = detail::function::unusable
807   >
808   class function :
809     public detail::function::get_function_impl<R, T1, T2, T3, T4, T5, T6, T7, 
810                                                T8, T9, T10>::type
811 #ifndef BOOST_FUNCTION_NO_DEPRECATED
812     , public detail::function::function_traits_builder<R, T1, T2, T3, T4, T5, 
813                                                        T6, T7, T8, T9, T10>
814 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
815   {
816     typedef typename detail::function::get_function_impl<R, T1, T2, T3, T4, T5,
817                                                          T6, T7, T8, T9, T10
818                                                          >::type 
819       base_type;
820
821   public:
822 #ifndef BOOST_FUNCTION_NO_DEPRECATED
823     typedef typename base_type::policy_type policy_type;
824     typedef typename base_type::mixin_type mixin_type;
825 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
826     typedef typename base_type::allocator_type allocator_type;              
827     typedef function self_type;                                     
828                                                                             
829     function() : base_type() {}                                     
830                                                                             
831     template<typename Functor>                                              
832     function(Functor BOOST_FUNCTION_TARGET_FIX(const &) f) : base_type(f) {}
833                       
834     function(const self_type& f) : base_type(static_cast<const base_type&>(f)){}
835          
836     template<typename Functor>
837     self_type& operator=(Functor BOOST_FUNCTION_TARGET_FIX(const &) f)
838     {
839       self_type(f).swap(*this);
840       return *this;
841     }
842
843     self_type& operator=(const base_type& f)
844     {
845       self_type(f).swap(*this);
846       return *this;
847     }
848
849     self_type& operator=(const self_type& f)
850     {   
851       self_type(f).swap(*this);
852       return *this;
853     }
854
855 #ifndef BOOST_FUNCTION_NO_DEPRECATED
856     template<typename Functor>
857     BOOST_FUNCTION_DEPRECATED_PRE 
858     void set(Functor BOOST_FUNCTION_TARGET_FIX(const &) f)
859     {
860       BOOST_FUNCTION_DEPRECATED_INNER
861       self_type(f).swap(*this);
862     }
863
864     BOOST_FUNCTION_DEPRECATED_PRE
865     void set(const base_type& f)
866     {
867       BOOST_FUNCTION_DEPRECATED_INNER
868       self_type(f).swap(*this);
869     }
870
871     BOOST_FUNCTION_DEPRECATED_PRE
872     void set(const self_type& f)                             
873     {
874       BOOST_FUNCTION_DEPRECATED_INNER
875       self_type(f).swap(*this);
876     }   
877 #endif // ndef BOOST_FUNCTION_NO_DEPRECATED
878   };
879
880   template<typename R,
881            typename T1, 
882            typename T2,
883            typename T3,
884            typename T4,
885            typename T5,
886            typename T6,
887            typename T7,
888            typename T8,
889            typename T9,
890            typename T10>
891   inline void swap(function<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& f1,
892                    function<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& f2)
893   {
894     f1.swap(f2);
895   }
896 } // end namespace boost
897
898 #endif // !no deprecated || !no partial specialization
899
900 #endif