Update contrib.
1 // Boost.Function library
3 // Copyright Douglas Gregor 2001-2006. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see http://www.boost.org
10 // Note: this header is a header template and must NOT have multiple-inclusion
12 #include <boost/function/detail/prologue.hpp>
14 #define BOOST_FUNCTION_TEMPLATE_PARMS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, typename T)
16 #define BOOST_FUNCTION_TEMPLATE_ARGS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, T)
18 #define BOOST_FUNCTION_PARM(J,I,D) BOOST_PP_CAT(T,I) BOOST_PP_CAT(a,I)
20 #define BOOST_FUNCTION_PARMS BOOST_PP_ENUM(BOOST_FUNCTION_NUM_ARGS,BOOST_FUNCTION_PARM,BOOST_PP_EMPTY)
22 #define BOOST_FUNCTION_ARGS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, a)
24 #define BOOST_FUNCTION_ARG_TYPE(J,I,D) \
25 typedef BOOST_PP_CAT(T,I) BOOST_PP_CAT(BOOST_PP_CAT(arg, BOOST_PP_INC(I)),_type);
27 #define BOOST_FUNCTION_ARG_TYPES BOOST_PP_REPEAT(BOOST_FUNCTION_NUM_ARGS,BOOST_FUNCTION_ARG_TYPE,BOOST_PP_EMPTY)
29 // Type of the default allocator
30 #ifndef BOOST_NO_STD_ALLOCATOR
31 # define BOOST_FUNCTION_DEFAULT_ALLOCATOR std::allocator<function_base>
33 # define BOOST_FUNCTION_DEFAULT_ALLOCATOR int
34 #endif // BOOST_NO_STD_ALLOCATOR
36 // Comma if nonzero number of arguments
37 #if BOOST_FUNCTION_NUM_ARGS == 0
38 # define BOOST_FUNCTION_COMMA
40 # define BOOST_FUNCTION_COMMA ,
41 #endif // BOOST_FUNCTION_NUM_ARGS > 0
43 // Class names used in this version of the code
44 #define BOOST_FUNCTION_FUNCTION BOOST_JOIN(function,BOOST_FUNCTION_NUM_ARGS)
45 #define BOOST_FUNCTION_FUNCTION_INVOKER \
46 BOOST_JOIN(function_invoker,BOOST_FUNCTION_NUM_ARGS)
47 #define BOOST_FUNCTION_VOID_FUNCTION_INVOKER \
48 BOOST_JOIN(void_function_invoker,BOOST_FUNCTION_NUM_ARGS)
49 #define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER \
50 BOOST_JOIN(function_obj_invoker,BOOST_FUNCTION_NUM_ARGS)
51 #define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER \
52 BOOST_JOIN(void_function_obj_invoker,BOOST_FUNCTION_NUM_ARGS)
53 #define BOOST_FUNCTION_FUNCTION_REF_INVOKER \
54 BOOST_JOIN(function_ref_invoker,BOOST_FUNCTION_NUM_ARGS)
55 #define BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER \
56 BOOST_JOIN(void_function_ref_invoker,BOOST_FUNCTION_NUM_ARGS)
57 #define BOOST_FUNCTION_GET_FUNCTION_INVOKER \
58 BOOST_JOIN(get_function_invoker,BOOST_FUNCTION_NUM_ARGS)
59 #define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER \
60 BOOST_JOIN(get_function_obj_invoker,BOOST_FUNCTION_NUM_ARGS)
61 #define BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER \
62 BOOST_JOIN(get_function_ref_invoker,BOOST_FUNCTION_NUM_ARGS)
63 #define BOOST_FUNCTION_VTABLE BOOST_JOIN(basic_vtable,BOOST_FUNCTION_NUM_ARGS)
65 #ifndef BOOST_NO_VOID_RETURNS
66 # define BOOST_FUNCTION_VOID_RETURN_TYPE void
67 # define BOOST_FUNCTION_RETURN(X) X
69 # define BOOST_FUNCTION_VOID_RETURN_TYPE boost::detail::function::unusable
70 # define BOOST_FUNCTION_RETURN(X) X; return BOOST_FUNCTION_VOID_RETURN_TYPE ()
74 # pragma warning(push)
75 # pragma warning(disable: 4127) // conditional expression is constant.
79 # pragma warning(push)
80 # pragma warning(disable: 4127) // conditional expression is constant.
88 typename R BOOST_FUNCTION_COMMA
89 BOOST_FUNCTION_TEMPLATE_PARMS
91 struct BOOST_FUNCTION_FUNCTION_INVOKER
93 static R invoke(function_buffer& function_ptr BOOST_FUNCTION_COMMA
96 FunctionPtr f = reinterpret_cast<FunctionPtr>(function_ptr.func_ptr);
97 return f(BOOST_FUNCTION_ARGS);
102 typename FunctionPtr,
103 typename R BOOST_FUNCTION_COMMA
104 BOOST_FUNCTION_TEMPLATE_PARMS
106 struct BOOST_FUNCTION_VOID_FUNCTION_INVOKER
108 static BOOST_FUNCTION_VOID_RETURN_TYPE
109 invoke(function_buffer& function_ptr BOOST_FUNCTION_COMMA
110 BOOST_FUNCTION_PARMS)
113 FunctionPtr f = reinterpret_cast<FunctionPtr>(function_ptr.func_ptr);
114 BOOST_FUNCTION_RETURN(f(BOOST_FUNCTION_ARGS));
119 typename FunctionObj,
120 typename R BOOST_FUNCTION_COMMA
121 BOOST_FUNCTION_TEMPLATE_PARMS
123 struct BOOST_FUNCTION_FUNCTION_OBJ_INVOKER
125 static R invoke(function_buffer& function_obj_ptr BOOST_FUNCTION_COMMA
126 BOOST_FUNCTION_PARMS)
130 if (function_allows_small_object_optimization<FunctionObj>::value)
131 f = reinterpret_cast<FunctionObj*>(&function_obj_ptr.data);
133 f = reinterpret_cast<FunctionObj*>(function_obj_ptr.obj_ptr);
134 return (*f)(BOOST_FUNCTION_ARGS);
139 typename FunctionObj,
140 typename R BOOST_FUNCTION_COMMA
141 BOOST_FUNCTION_TEMPLATE_PARMS
143 struct BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER
145 static BOOST_FUNCTION_VOID_RETURN_TYPE
146 invoke(function_buffer& function_obj_ptr BOOST_FUNCTION_COMMA
147 BOOST_FUNCTION_PARMS)
151 if (function_allows_small_object_optimization<FunctionObj>::value)
152 f = reinterpret_cast<FunctionObj*>(&function_obj_ptr.data);
154 f = reinterpret_cast<FunctionObj*>(function_obj_ptr.obj_ptr);
155 BOOST_FUNCTION_RETURN((*f)(BOOST_FUNCTION_ARGS));
160 typename FunctionObj,
161 typename R BOOST_FUNCTION_COMMA
162 BOOST_FUNCTION_TEMPLATE_PARMS
164 struct BOOST_FUNCTION_FUNCTION_REF_INVOKER
166 static R invoke(function_buffer& function_obj_ptr BOOST_FUNCTION_COMMA
167 BOOST_FUNCTION_PARMS)
171 reinterpret_cast<FunctionObj*>(function_obj_ptr.obj_ptr);
172 return (*f)(BOOST_FUNCTION_ARGS);
177 typename FunctionObj,
178 typename R BOOST_FUNCTION_COMMA
179 BOOST_FUNCTION_TEMPLATE_PARMS
181 struct BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER
183 static BOOST_FUNCTION_VOID_RETURN_TYPE
184 invoke(function_buffer& function_obj_ptr BOOST_FUNCTION_COMMA
185 BOOST_FUNCTION_PARMS)
189 reinterpret_cast<FunctionObj*>(function_obj_ptr.obj_ptr);
190 BOOST_FUNCTION_RETURN((*f)(BOOST_FUNCTION_ARGS));
195 typename FunctionPtr,
196 typename R BOOST_FUNCTION_COMMA
197 BOOST_FUNCTION_TEMPLATE_PARMS
199 struct BOOST_FUNCTION_GET_FUNCTION_INVOKER
201 typedef typename mpl::if_c<(is_void<R>::value),
202 BOOST_FUNCTION_VOID_FUNCTION_INVOKER<
204 R BOOST_FUNCTION_COMMA
205 BOOST_FUNCTION_TEMPLATE_ARGS
207 BOOST_FUNCTION_FUNCTION_INVOKER<
209 R BOOST_FUNCTION_COMMA
210 BOOST_FUNCTION_TEMPLATE_ARGS
216 typename FunctionObj,
217 typename R BOOST_FUNCTION_COMMA
218 BOOST_FUNCTION_TEMPLATE_PARMS
220 struct BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER
222 typedef typename mpl::if_c<(is_void<R>::value),
223 BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER<
225 R BOOST_FUNCTION_COMMA
226 BOOST_FUNCTION_TEMPLATE_ARGS
228 BOOST_FUNCTION_FUNCTION_OBJ_INVOKER<
230 R BOOST_FUNCTION_COMMA
231 BOOST_FUNCTION_TEMPLATE_ARGS
237 typename FunctionObj,
238 typename R BOOST_FUNCTION_COMMA
239 BOOST_FUNCTION_TEMPLATE_PARMS
241 struct BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER
243 typedef typename mpl::if_c<(is_void<R>::value),
244 BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER<
246 R BOOST_FUNCTION_COMMA
247 BOOST_FUNCTION_TEMPLATE_ARGS
249 BOOST_FUNCTION_FUNCTION_REF_INVOKER<
251 R BOOST_FUNCTION_COMMA
252 BOOST_FUNCTION_TEMPLATE_ARGS
258 * vtable for a specific boost::function instance.
260 template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
262 struct BOOST_FUNCTION_VTABLE : vtable_base
264 #ifndef BOOST_NO_VOID_RETURNS
265 typedef R result_type;
267 typedef typename function_return_type<R>::type result_type;
268 #endif // BOOST_NO_VOID_RETURNS
270 typedef result_type (*invoker_type)(function_buffer&
272 BOOST_FUNCTION_TEMPLATE_ARGS);
275 BOOST_FUNCTION_VTABLE(F f) : vtable_base(), invoker(0)
281 bool assign_to(F f, function_buffer& functor)
283 typedef typename get_function_tag<F>::type tag;
284 return assign_to(f, functor, tag());
287 void clear(function_buffer& functor)
290 manager(functor, functor, destroy_functor_tag);
297 typedef typename get_function_tag<F>::type tag;
302 template<typename FunctionPtr>
303 void init(FunctionPtr /*f*/, function_ptr_tag)
305 typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
307 R BOOST_FUNCTION_COMMA
308 BOOST_FUNCTION_TEMPLATE_ARGS
312 invoker = &actual_invoker_type::invoke;
313 manager = &functor_manager<FunctionPtr, Allocator>::manage;
316 template<typename FunctionPtr>
318 assign_to(FunctionPtr f, function_buffer& functor, function_ptr_tag)
320 this->clear(functor);
322 // should be a reinterpret cast, but some compilers insist
323 // on giving cv-qualifiers to free functions
324 functor.func_ptr = (void (*)())(f);
332 #if BOOST_FUNCTION_NUM_ARGS > 0
333 template<typename MemberPtr>
334 void init(MemberPtr f, member_ptr_tag)
336 // DPG TBD: Add explicit support for member function
337 // objects, so we invoke through mem_fn() but we retain the
338 // right target_type() values.
339 this->init(mem_fn(f));
342 template<typename MemberPtr>
343 bool assign_to(MemberPtr f, function_buffer& functor, member_ptr_tag)
345 // DPG TBD: Add explicit support for member function
346 // objects, so we invoke through mem_fn() but we retain the
347 // right target_type() values.
349 this->assign_to(mem_fn(f), functor);
355 #endif // BOOST_FUNCTION_NUM_ARGS > 0
358 template<typename FunctionObj>
359 void init(FunctionObj /*f*/, function_obj_tag)
361 typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
363 R BOOST_FUNCTION_COMMA
364 BOOST_FUNCTION_TEMPLATE_ARGS
368 invoker = &actual_invoker_type::invoke;
369 manager = &functor_manager<FunctionObj, Allocator>::manage;
372 // Assign to a function object using the small object optimization
373 template<typename FunctionObj>
375 assign_functor(FunctionObj f, function_buffer& functor, mpl::true_)
377 new ((void*)&functor.data) FunctionObj(f);
380 // Assign to a function object allocated on the heap.
381 template<typename FunctionObj>
383 assign_functor(FunctionObj f, function_buffer& functor, mpl::false_)
385 #ifndef BOOST_NO_STD_ALLOCATOR
386 typedef typename Allocator::template rebind<FunctionObj>::other
388 typedef typename allocator_type::pointer pointer_type;
390 allocator_type allocator;
391 pointer_type copy = allocator.allocate(1);
392 allocator.construct(copy, f);
394 // Get back to the original pointer type
395 functor.obj_ptr = static_cast<FunctionObj*>(copy);
397 functor.obj_ptr = new FunctionObj(f);
398 # endif // BOOST_NO_STD_ALLOCATOR
401 template<typename FunctionObj>
403 assign_to(FunctionObj f, function_buffer& functor, function_obj_tag)
405 if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
406 assign_functor(f, functor,
407 mpl::bool_<(function_allows_small_object_optimization<FunctionObj>::value)>());
414 // Reference to a function object
415 template<typename FunctionObj>
417 init(const reference_wrapper<FunctionObj>& /*f*/, function_obj_ref_tag)
419 typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER<
421 R BOOST_FUNCTION_COMMA
422 BOOST_FUNCTION_TEMPLATE_ARGS
426 invoker = &actual_invoker_type::invoke;
427 manager = &reference_manager<FunctionObj>::get;
430 template<typename FunctionObj>
432 assign_to(const reference_wrapper<FunctionObj>& f,
433 function_buffer& functor, function_obj_ref_tag)
435 if (!boost::detail::function::has_empty_target(f.get_pointer())) {
436 // DPG TBD: We might need to detect constness of
437 // FunctionObj to assign into obj_ptr or const_obj_ptr to
438 // be truly legit, but no platform in existence makes
439 // const void* different from void*.
440 functor.const_obj_ptr = f.get_pointer();
448 invoker_type invoker;
450 } // end namespace function
451 } // end namespace detail
454 typename R BOOST_FUNCTION_COMMA
455 BOOST_FUNCTION_TEMPLATE_PARMS,
456 typename Allocator = BOOST_FUNCTION_DEFAULT_ALLOCATOR
458 class BOOST_FUNCTION_FUNCTION : public function_base
461 #ifndef BOOST_NO_VOID_RETURNS
462 typedef R result_type;
464 typedef typename boost::detail::function::function_return_type<R>::type
466 #endif // BOOST_NO_VOID_RETURNS
469 typedef boost::detail::function::BOOST_FUNCTION_VTABLE<
470 R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS, Allocator>
473 struct clear_type {};
476 BOOST_STATIC_CONSTANT(int, args = BOOST_FUNCTION_NUM_ARGS);
478 // add signature for boost::lambda
479 template<typename Args>
482 typedef result_type type;
485 #if BOOST_FUNCTION_NUM_ARGS == 1
486 typedef T0 argument_type;
487 #elif BOOST_FUNCTION_NUM_ARGS == 2
488 typedef T0 first_argument_type;
489 typedef T1 second_argument_type;
492 BOOST_STATIC_CONSTANT(int, arity = BOOST_FUNCTION_NUM_ARGS);
493 BOOST_FUNCTION_ARG_TYPES
495 typedef Allocator allocator_type;
496 typedef BOOST_FUNCTION_FUNCTION self_type;
498 BOOST_FUNCTION_FUNCTION() : function_base() { }
500 // MSVC chokes if the following two constructors are collapsed into
501 // one with a default parameter.
502 template<typename Functor>
503 BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f
504 #ifndef BOOST_NO_SFINAE
505 ,typename enable_if_c<
506 (boost::type_traits::ice_not<
507 (is_integral<Functor>::value)>::value),
509 #endif // BOOST_NO_SFINAE
516 #ifndef BOOST_NO_SFINAE
517 BOOST_FUNCTION_FUNCTION(clear_type*) : function_base() { }
519 BOOST_FUNCTION_FUNCTION(int zero) : function_base()
521 BOOST_ASSERT(zero == 0);
525 BOOST_FUNCTION_FUNCTION(const BOOST_FUNCTION_FUNCTION& f) : function_base()
527 this->assign_to_own(f);
530 ~BOOST_FUNCTION_FUNCTION() { clear(); }
532 #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
533 // MSVC 6.0 and prior require all definitions to be inline, but
534 // these definitions can become very costly.
535 result_type operator()(BOOST_FUNCTION_PARMS) const
538 boost::throw_exception(bad_function_call());
540 return static_cast<vtable_type*>(vtable)->invoker
541 (this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS);
544 result_type operator()(BOOST_FUNCTION_PARMS) const;
547 // The distinction between when to use BOOST_FUNCTION_FUNCTION and
548 // when to use self_type is obnoxious. MSVC cannot handle self_type as
549 // the return type of these assignment operators, but Borland C++ cannot
550 // handle BOOST_FUNCTION_FUNCTION as the type of the temporary to
552 template<typename Functor>
553 #ifndef BOOST_NO_SFINAE
554 typename enable_if_c<
555 (boost::type_traits::ice_not<
556 (is_integral<Functor>::value)>::value),
557 BOOST_FUNCTION_FUNCTION&>::type
559 BOOST_FUNCTION_FUNCTION&
561 operator=(Functor BOOST_FUNCTION_TARGET_FIX(const &) f)
573 #ifndef BOOST_NO_SFINAE
574 BOOST_FUNCTION_FUNCTION& operator=(clear_type*)
580 BOOST_FUNCTION_FUNCTION& operator=(int zero)
582 BOOST_ASSERT(zero == 0);
588 // Assignment from another BOOST_FUNCTION_FUNCTION
589 BOOST_FUNCTION_FUNCTION& operator=(const BOOST_FUNCTION_FUNCTION& f)
596 this->assign_to_own(f);
604 void swap(BOOST_FUNCTION_FUNCTION& other)
609 BOOST_FUNCTION_FUNCTION tmp = *this;
614 // Clear out a target, if there is one
618 static_cast<vtable_type*>(vtable)->clear(this->functor);
623 #if (defined __SUNPRO_CC) && (__SUNPRO_CC <= 0x530) && !(defined BOOST_NO_COMPILER_CONFIG)
624 // Sun C++ 5.3 can't handle the safe_bool idiom, so don't use it
625 operator bool () const { return !this->empty(); }
632 typedef void (dummy::*safe_bool)();
635 operator safe_bool () const
636 { return (this->empty())? 0 : &dummy::nonnull; }
638 bool operator!() const
639 { return this->empty(); }
643 void assign_to_own(const BOOST_FUNCTION_FUNCTION& f)
646 this->vtable = f.vtable;
647 f.vtable->manager(f.functor, this->functor,
648 boost::detail::function::clone_functor_tag);
652 template<typename Functor>
653 void assign_to(Functor f)
655 static vtable_type stored_vtable(f);
656 if (stored_vtable.assign_to(f, functor)) vtable = &stored_vtable;
661 template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
663 inline void swap(BOOST_FUNCTION_FUNCTION<
664 R BOOST_FUNCTION_COMMA
665 BOOST_FUNCTION_TEMPLATE_ARGS ,
668 BOOST_FUNCTION_FUNCTION<
669 R BOOST_FUNCTION_COMMA
670 BOOST_FUNCTION_TEMPLATE_ARGS,
677 #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
678 template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
680 typename BOOST_FUNCTION_FUNCTION<
681 R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS,
682 Allocator>::result_type
683 BOOST_FUNCTION_FUNCTION<R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS,
686 ::operator()(BOOST_FUNCTION_PARMS) const
689 boost::throw_exception(bad_function_call());
691 return static_cast<vtable_type*>(vtable)->invoker
692 (this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS);
696 // Poison comparisons between boost::function objects of the same type.
697 template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
699 void operator==(const BOOST_FUNCTION_FUNCTION<
700 R BOOST_FUNCTION_COMMA
701 BOOST_FUNCTION_TEMPLATE_ARGS ,
703 const BOOST_FUNCTION_FUNCTION<
704 R BOOST_FUNCTION_COMMA
705 BOOST_FUNCTION_TEMPLATE_ARGS ,
707 template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
709 void operator!=(const BOOST_FUNCTION_FUNCTION<
710 R BOOST_FUNCTION_COMMA
711 BOOST_FUNCTION_TEMPLATE_ARGS ,
713 const BOOST_FUNCTION_FUNCTION<
714 R BOOST_FUNCTION_COMMA
715 BOOST_FUNCTION_TEMPLATE_ARGS ,
718 #if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
720 #if BOOST_FUNCTION_NUM_ARGS == 0
721 #define BOOST_FUNCTION_PARTIAL_SPEC R (void)
723 #define BOOST_FUNCTION_PARTIAL_SPEC R (BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS,T))
726 template<typename R BOOST_FUNCTION_COMMA
727 BOOST_FUNCTION_TEMPLATE_PARMS,
729 class function<BOOST_FUNCTION_PARTIAL_SPEC, Allocator>
730 : public BOOST_FUNCTION_FUNCTION<R, BOOST_FUNCTION_TEMPLATE_ARGS
731 BOOST_FUNCTION_COMMA Allocator>
733 typedef BOOST_FUNCTION_FUNCTION<R, BOOST_FUNCTION_TEMPLATE_ARGS
734 BOOST_FUNCTION_COMMA Allocator> base_type;
735 typedef function self_type;
737 struct clear_type {};
740 typedef typename base_type::allocator_type allocator_type;
742 function() : base_type() {}
744 template<typename Functor>
746 #ifndef BOOST_NO_SFINAE
747 ,typename enable_if_c<
748 (boost::type_traits::ice_not<
749 (is_integral<Functor>::value)>::value),
757 #ifndef BOOST_NO_SFINAE
758 function(clear_type*) : base_type() {}
761 function(const self_type& f) : base_type(static_cast<const base_type&>(f)){}
763 function(const base_type& f) : base_type(static_cast<const base_type&>(f)){}
765 self_type& operator=(const self_type& f)
767 self_type(f).swap(*this);
771 template<typename Functor>
772 #ifndef BOOST_NO_SFINAE
773 typename enable_if_c<
774 (boost::type_traits::ice_not<
775 (is_integral<Functor>::value)>::value),
782 self_type(f).swap(*this);
786 #ifndef BOOST_NO_SFINAE
787 self_type& operator=(clear_type*)
794 self_type& operator=(const base_type& f)
796 self_type(f).swap(*this);
802 # pragma warning(pop)
805 #undef BOOST_FUNCTION_PARTIAL_SPEC
806 #endif // have partial specialization
808 } // end namespace boost
811 # pragma warning(pop)
814 // Cleanup after ourselves...
815 #undef BOOST_FUNCTION_VTABLE
816 #undef BOOST_FUNCTION_DEFAULT_ALLOCATOR
817 #undef BOOST_FUNCTION_COMMA
818 #undef BOOST_FUNCTION_FUNCTION
819 #undef BOOST_FUNCTION_FUNCTION_INVOKER
820 #undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER
821 #undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER
822 #undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER
823 #undef BOOST_FUNCTION_FUNCTION_REF_INVOKER
824 #undef BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER
825 #undef BOOST_FUNCTION_GET_FUNCTION_INVOKER
826 #undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER
827 #undef BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER
828 #undef BOOST_FUNCTION_GET_MEM_FUNCTION_INVOKER
829 #undef BOOST_FUNCTION_TEMPLATE_PARMS
830 #undef BOOST_FUNCTION_TEMPLATE_ARGS
831 #undef BOOST_FUNCTION_PARMS
832 #undef BOOST_FUNCTION_PARM
833 #undef BOOST_FUNCTION_ARGS
834 #undef BOOST_FUNCTION_ARG_TYPE
835 #undef BOOST_FUNCTION_ARG_TYPES
836 #undef BOOST_FUNCTION_VOID_RETURN_TYPE
837 #undef BOOST_FUNCTION_RETURN