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