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 ()
78 typename R BOOST_FUNCTION_COMMA
79 BOOST_FUNCTION_TEMPLATE_PARMS
81 struct BOOST_FUNCTION_FUNCTION_INVOKER
83 static R invoke(function_buffer& function_ptr BOOST_FUNCTION_COMMA
86 FunctionPtr f = reinterpret_cast<FunctionPtr>(function_ptr.func_ptr);
87 return f(BOOST_FUNCTION_ARGS);
93 typename R BOOST_FUNCTION_COMMA
94 BOOST_FUNCTION_TEMPLATE_PARMS
96 struct BOOST_FUNCTION_VOID_FUNCTION_INVOKER
98 static BOOST_FUNCTION_VOID_RETURN_TYPE
99 invoke(function_buffer& function_ptr BOOST_FUNCTION_COMMA
100 BOOST_FUNCTION_PARMS)
103 FunctionPtr f = reinterpret_cast<FunctionPtr>(function_ptr.func_ptr);
104 BOOST_FUNCTION_RETURN(f(BOOST_FUNCTION_ARGS));
109 typename FunctionObj,
110 typename R BOOST_FUNCTION_COMMA
111 BOOST_FUNCTION_TEMPLATE_PARMS
113 struct BOOST_FUNCTION_FUNCTION_OBJ_INVOKER
115 static R invoke(function_buffer& function_obj_ptr BOOST_FUNCTION_COMMA
116 BOOST_FUNCTION_PARMS)
120 if (function_allows_small_object_optimization<FunctionObj>::value)
121 f = reinterpret_cast<FunctionObj*>(&function_obj_ptr.data);
123 f = reinterpret_cast<FunctionObj*>(function_obj_ptr.obj_ptr);
124 return (*f)(BOOST_FUNCTION_ARGS);
129 typename FunctionObj,
130 typename R BOOST_FUNCTION_COMMA
131 BOOST_FUNCTION_TEMPLATE_PARMS
133 struct BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER
135 static BOOST_FUNCTION_VOID_RETURN_TYPE
136 invoke(function_buffer& function_obj_ptr BOOST_FUNCTION_COMMA
137 BOOST_FUNCTION_PARMS)
141 if (function_allows_small_object_optimization<FunctionObj>::value)
142 f = reinterpret_cast<FunctionObj*>(&function_obj_ptr.data);
144 f = reinterpret_cast<FunctionObj*>(function_obj_ptr.obj_ptr);
145 BOOST_FUNCTION_RETURN((*f)(BOOST_FUNCTION_ARGS));
150 typename FunctionObj,
151 typename R BOOST_FUNCTION_COMMA
152 BOOST_FUNCTION_TEMPLATE_PARMS
154 struct BOOST_FUNCTION_FUNCTION_REF_INVOKER
156 static R invoke(function_buffer& function_obj_ptr BOOST_FUNCTION_COMMA
157 BOOST_FUNCTION_PARMS)
161 reinterpret_cast<FunctionObj*>(function_obj_ptr.obj_ptr);
162 return (*f)(BOOST_FUNCTION_ARGS);
167 typename FunctionObj,
168 typename R BOOST_FUNCTION_COMMA
169 BOOST_FUNCTION_TEMPLATE_PARMS
171 struct BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER
173 static BOOST_FUNCTION_VOID_RETURN_TYPE
174 invoke(function_buffer& function_obj_ptr BOOST_FUNCTION_COMMA
175 BOOST_FUNCTION_PARMS)
179 reinterpret_cast<FunctionObj*>(function_obj_ptr.obj_ptr);
180 BOOST_FUNCTION_RETURN((*f)(BOOST_FUNCTION_ARGS));
185 typename FunctionPtr,
186 typename R BOOST_FUNCTION_COMMA
187 BOOST_FUNCTION_TEMPLATE_PARMS
189 struct BOOST_FUNCTION_GET_FUNCTION_INVOKER
191 typedef typename mpl::if_c<(is_void<R>::value),
192 BOOST_FUNCTION_VOID_FUNCTION_INVOKER<
194 R BOOST_FUNCTION_COMMA
195 BOOST_FUNCTION_TEMPLATE_ARGS
197 BOOST_FUNCTION_FUNCTION_INVOKER<
199 R BOOST_FUNCTION_COMMA
200 BOOST_FUNCTION_TEMPLATE_ARGS
206 typename FunctionObj,
207 typename R BOOST_FUNCTION_COMMA
208 BOOST_FUNCTION_TEMPLATE_PARMS
210 struct BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER
212 typedef typename mpl::if_c<(is_void<R>::value),
213 BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER<
215 R BOOST_FUNCTION_COMMA
216 BOOST_FUNCTION_TEMPLATE_ARGS
218 BOOST_FUNCTION_FUNCTION_OBJ_INVOKER<
220 R BOOST_FUNCTION_COMMA
221 BOOST_FUNCTION_TEMPLATE_ARGS
227 typename FunctionObj,
228 typename R BOOST_FUNCTION_COMMA
229 BOOST_FUNCTION_TEMPLATE_PARMS
231 struct BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER
233 typedef typename mpl::if_c<(is_void<R>::value),
234 BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER<
236 R BOOST_FUNCTION_COMMA
237 BOOST_FUNCTION_TEMPLATE_ARGS
239 BOOST_FUNCTION_FUNCTION_REF_INVOKER<
241 R BOOST_FUNCTION_COMMA
242 BOOST_FUNCTION_TEMPLATE_ARGS
248 * vtable for a specific boost::function instance.
250 template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
252 struct BOOST_FUNCTION_VTABLE : vtable_base
254 #ifndef BOOST_NO_VOID_RETURNS
255 typedef R result_type;
257 typedef typename function_return_type<R>::type result_type;
258 #endif // BOOST_NO_VOID_RETURNS
260 typedef result_type (*invoker_type)(function_buffer&
262 BOOST_FUNCTION_TEMPLATE_ARGS);
265 BOOST_FUNCTION_VTABLE(F f) : vtable_base(), invoker(0)
271 bool assign_to(F f, function_buffer& functor)
273 typedef typename get_function_tag<F>::type tag;
274 return assign_to(f, functor, tag());
277 void clear(function_buffer& functor)
280 manager(functor, functor, destroy_functor_tag);
287 typedef typename get_function_tag<F>::type tag;
292 template<typename FunctionPtr>
293 void init(FunctionPtr /*f*/, function_ptr_tag)
295 typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
297 R BOOST_FUNCTION_COMMA
298 BOOST_FUNCTION_TEMPLATE_ARGS
302 invoker = &actual_invoker_type::invoke;
303 manager = &functor_manager<FunctionPtr, Allocator>::manage;
306 template<typename FunctionPtr>
308 assign_to(FunctionPtr f, function_buffer& functor, function_ptr_tag)
310 this->clear(functor);
312 // should be a reinterpret cast, but some compilers insist
313 // on giving cv-qualifiers to free functions
314 functor.func_ptr = (void (*)())(f);
322 #if BOOST_FUNCTION_NUM_ARGS > 0
323 template<typename MemberPtr>
324 void init(MemberPtr f, member_ptr_tag)
326 // DPG TBD: Add explicit support for member function
327 // objects, so we invoke through mem_fn() but we retain the
328 // right target_type() values.
329 this->init(mem_fn(f));
332 template<typename MemberPtr>
333 bool assign_to(MemberPtr f, function_buffer& functor, member_ptr_tag)
335 // DPG TBD: Add explicit support for member function
336 // objects, so we invoke through mem_fn() but we retain the
337 // right target_type() values.
339 this->assign_to(mem_fn(f), functor);
345 #endif // BOOST_FUNCTION_NUM_ARGS > 0
348 template<typename FunctionObj>
349 void init(FunctionObj /*f*/, function_obj_tag)
351 typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
353 R BOOST_FUNCTION_COMMA
354 BOOST_FUNCTION_TEMPLATE_ARGS
358 invoker = &actual_invoker_type::invoke;
359 manager = &functor_manager<FunctionObj, Allocator>::manage;
362 // Assign to a function object using the small object optimization
363 template<typename FunctionObj>
365 assign_functor(FunctionObj f, function_buffer& functor, mpl::true_)
367 new ((void*)&functor.data) FunctionObj(f);
370 // Assign to a function object allocated on the heap.
371 template<typename FunctionObj>
373 assign_functor(FunctionObj f, function_buffer& functor, mpl::false_)
375 #ifndef BOOST_NO_STD_ALLOCATOR
376 typedef typename Allocator::template rebind<FunctionObj>::other
378 typedef typename allocator_type::pointer pointer_type;
380 allocator_type allocator;
381 pointer_type copy = allocator.allocate(1);
382 allocator.construct(copy, f);
384 // Get back to the original pointer type
385 functor.obj_ptr = static_cast<FunctionObj*>(copy);
387 functor.obj_ptr = new FunctionObj(f);
388 # endif // BOOST_NO_STD_ALLOCATOR
391 template<typename FunctionObj>
393 assign_to(FunctionObj f, function_buffer& functor, function_obj_tag)
395 if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
396 assign_functor(f, functor,
397 mpl::bool_<(function_allows_small_object_optimization<FunctionObj>::value)>());
404 // Reference to a function object
405 template<typename FunctionObj>
407 init(const reference_wrapper<FunctionObj>& /*f*/, function_obj_ref_tag)
409 typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER<
411 R BOOST_FUNCTION_COMMA
412 BOOST_FUNCTION_TEMPLATE_ARGS
416 invoker = &actual_invoker_type::invoke;
417 manager = &reference_manager<FunctionObj>::get;
420 template<typename FunctionObj>
422 assign_to(const reference_wrapper<FunctionObj>& f,
423 function_buffer& functor, function_obj_ref_tag)
425 if (!boost::detail::function::has_empty_target(f.get_pointer())) {
426 // DPG TBD: We might need to detect constness of
427 // FunctionObj to assign into obj_ptr or const_obj_ptr to
428 // be truly legit, but no platform in existence makes
429 // const void* different from void*.
430 functor.const_obj_ptr = f.get_pointer();
438 invoker_type invoker;
440 } // end namespace function
441 } // end namespace detail
444 typename R BOOST_FUNCTION_COMMA
445 BOOST_FUNCTION_TEMPLATE_PARMS,
446 typename Allocator = BOOST_FUNCTION_DEFAULT_ALLOCATOR
448 class BOOST_FUNCTION_FUNCTION : public function_base
451 #ifndef BOOST_NO_VOID_RETURNS
452 typedef R result_type;
454 typedef typename boost::detail::function::function_return_type<R>::type
456 #endif // BOOST_NO_VOID_RETURNS
459 typedef boost::detail::function::BOOST_FUNCTION_VTABLE<
460 R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS, Allocator>
463 struct clear_type {};
466 BOOST_STATIC_CONSTANT(int, args = BOOST_FUNCTION_NUM_ARGS);
468 // add signature for boost::lambda
469 template<typename Args>
472 typedef result_type type;
475 #if BOOST_FUNCTION_NUM_ARGS == 1
476 typedef T0 argument_type;
477 #elif BOOST_FUNCTION_NUM_ARGS == 2
478 typedef T0 first_argument_type;
479 typedef T1 second_argument_type;
482 BOOST_STATIC_CONSTANT(int, arity = BOOST_FUNCTION_NUM_ARGS);
483 BOOST_FUNCTION_ARG_TYPES
485 typedef Allocator allocator_type;
486 typedef BOOST_FUNCTION_FUNCTION self_type;
488 BOOST_FUNCTION_FUNCTION() : function_base() { }
490 // MSVC chokes if the following two constructors are collapsed into
491 // one with a default parameter.
492 template<typename Functor>
493 BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f
494 #ifndef BOOST_NO_SFINAE
495 ,typename enable_if_c<
496 (boost::type_traits::ice_not<
497 (is_integral<Functor>::value)>::value),
499 #endif // BOOST_NO_SFINAE
506 #ifndef BOOST_NO_SFINAE
507 BOOST_FUNCTION_FUNCTION(clear_type*) : function_base() { }
509 BOOST_FUNCTION_FUNCTION(int zero) : function_base()
511 BOOST_ASSERT(zero == 0);
515 BOOST_FUNCTION_FUNCTION(const BOOST_FUNCTION_FUNCTION& f) : function_base()
517 this->assign_to_own(f);
520 ~BOOST_FUNCTION_FUNCTION() { clear(); }
522 #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
523 // MSVC 6.0 and prior require all definitions to be inline, but
524 // these definitions can become very costly.
525 result_type operator()(BOOST_FUNCTION_PARMS) const
528 boost::throw_exception(bad_function_call());
530 return static_cast<vtable_type*>(vtable)->invoker
531 (this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS);
534 result_type operator()(BOOST_FUNCTION_PARMS) const;
537 // The distinction between when to use BOOST_FUNCTION_FUNCTION and
538 // when to use self_type is obnoxious. MSVC cannot handle self_type as
539 // the return type of these assignment operators, but Borland C++ cannot
540 // handle BOOST_FUNCTION_FUNCTION as the type of the temporary to
542 template<typename Functor>
543 #ifndef BOOST_NO_SFINAE
544 typename enable_if_c<
545 (boost::type_traits::ice_not<
546 (is_integral<Functor>::value)>::value),
547 BOOST_FUNCTION_FUNCTION&>::type
549 BOOST_FUNCTION_FUNCTION&
551 operator=(Functor BOOST_FUNCTION_TARGET_FIX(const &) f)
563 #ifndef BOOST_NO_SFINAE
564 BOOST_FUNCTION_FUNCTION& operator=(clear_type*)
570 BOOST_FUNCTION_FUNCTION& operator=(int zero)
572 BOOST_ASSERT(zero == 0);
578 // Assignment from another BOOST_FUNCTION_FUNCTION
579 BOOST_FUNCTION_FUNCTION& operator=(const BOOST_FUNCTION_FUNCTION& f)
586 this->assign_to_own(f);
594 void swap(BOOST_FUNCTION_FUNCTION& other)
599 BOOST_FUNCTION_FUNCTION tmp = *this;
604 // Clear out a target, if there is one
608 static_cast<vtable_type*>(vtable)->clear(this->functor);
613 #if (defined __SUNPRO_CC) && (__SUNPRO_CC <= 0x530) && !(defined BOOST_NO_COMPILER_CONFIG)
614 // Sun C++ 5.3 can't handle the safe_bool idiom, so don't use it
615 operator bool () const { return !this->empty(); }
622 typedef void (dummy::*safe_bool)();
625 operator safe_bool () const
626 { return (this->empty())? 0 : &dummy::nonnull; }
628 bool operator!() const
629 { return this->empty(); }
633 void assign_to_own(const BOOST_FUNCTION_FUNCTION& f)
636 this->vtable = f.vtable;
637 f.vtable->manager(f.functor, this->functor,
638 boost::detail::function::clone_functor_tag);
642 template<typename Functor>
643 void assign_to(Functor f)
645 static vtable_type stored_vtable(f);
646 if (stored_vtable.assign_to(f, functor)) vtable = &stored_vtable;
651 template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
653 inline void swap(BOOST_FUNCTION_FUNCTION<
654 R BOOST_FUNCTION_COMMA
655 BOOST_FUNCTION_TEMPLATE_ARGS ,
658 BOOST_FUNCTION_FUNCTION<
659 R BOOST_FUNCTION_COMMA
660 BOOST_FUNCTION_TEMPLATE_ARGS,
667 #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
668 template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
670 typename BOOST_FUNCTION_FUNCTION<
671 R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS,
672 Allocator>::result_type
673 BOOST_FUNCTION_FUNCTION<R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS,
676 ::operator()(BOOST_FUNCTION_PARMS) const
679 boost::throw_exception(bad_function_call());
681 return static_cast<vtable_type*>(vtable)->invoker
682 (this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS);
686 // Poison comparisons between boost::function objects of the same type.
687 template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
689 void operator==(const BOOST_FUNCTION_FUNCTION<
690 R BOOST_FUNCTION_COMMA
691 BOOST_FUNCTION_TEMPLATE_ARGS ,
693 const BOOST_FUNCTION_FUNCTION<
694 R BOOST_FUNCTION_COMMA
695 BOOST_FUNCTION_TEMPLATE_ARGS ,
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 ,
708 #if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
710 #if BOOST_FUNCTION_NUM_ARGS == 0
711 #define BOOST_FUNCTION_PARTIAL_SPEC R (void)
713 #define BOOST_FUNCTION_PARTIAL_SPEC R (BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS,T))
716 template<typename R BOOST_FUNCTION_COMMA
717 BOOST_FUNCTION_TEMPLATE_PARMS,
719 class function<BOOST_FUNCTION_PARTIAL_SPEC, Allocator>
720 : public BOOST_FUNCTION_FUNCTION<R, BOOST_FUNCTION_TEMPLATE_ARGS
721 BOOST_FUNCTION_COMMA Allocator>
723 typedef BOOST_FUNCTION_FUNCTION<R, BOOST_FUNCTION_TEMPLATE_ARGS
724 BOOST_FUNCTION_COMMA Allocator> base_type;
725 typedef function self_type;
727 struct clear_type {};
730 typedef typename base_type::allocator_type allocator_type;
732 function() : base_type() {}
734 template<typename Functor>
736 #ifndef BOOST_NO_SFINAE
737 ,typename enable_if_c<
738 (boost::type_traits::ice_not<
739 (is_integral<Functor>::value)>::value),
747 #ifndef BOOST_NO_SFINAE
748 function(clear_type*) : base_type() {}
751 function(const self_type& f) : base_type(static_cast<const base_type&>(f)){}
753 function(const base_type& f) : base_type(static_cast<const base_type&>(f)){}
755 self_type& operator=(const self_type& f)
757 self_type(f).swap(*this);
761 template<typename Functor>
762 #ifndef BOOST_NO_SFINAE
763 typename enable_if_c<
764 (boost::type_traits::ice_not<
765 (is_integral<Functor>::value)>::value),
772 self_type(f).swap(*this);
776 #ifndef BOOST_NO_SFINAE
777 self_type& operator=(clear_type*)
784 self_type& operator=(const base_type& f)
786 self_type(f).swap(*this);
791 #undef BOOST_FUNCTION_PARTIAL_SPEC
792 #endif // have partial specialization
794 } // end namespace boost
796 // Cleanup after ourselves...
797 #undef BOOST_FUNCTION_VTABLE
798 #undef BOOST_FUNCTION_DEFAULT_ALLOCATOR
799 #undef BOOST_FUNCTION_COMMA
800 #undef BOOST_FUNCTION_FUNCTION
801 #undef BOOST_FUNCTION_FUNCTION_INVOKER
802 #undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER
803 #undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER
804 #undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER
805 #undef BOOST_FUNCTION_FUNCTION_REF_INVOKER
806 #undef BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER
807 #undef BOOST_FUNCTION_GET_FUNCTION_INVOKER
808 #undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER
809 #undef BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER
810 #undef BOOST_FUNCTION_GET_MEM_FUNCTION_INVOKER
811 #undef BOOST_FUNCTION_TEMPLATE_PARMS
812 #undef BOOST_FUNCTION_TEMPLATE_ARGS
813 #undef BOOST_FUNCTION_PARMS
814 #undef BOOST_FUNCTION_PARM
815 #undef BOOST_FUNCTION_ARGS
816 #undef BOOST_FUNCTION_ARG_TYPE
817 #undef BOOST_FUNCTION_ARG_TYPES
818 #undef BOOST_FUNCTION_VOID_RETURN_TYPE
819 #undef BOOST_FUNCTION_RETURN