1 // Boost.Function library
3 // Copyright Douglas Gregor 2001-2006
4 // Copyright Emil Dotchevski 2007
5 // Use, modification and distribution is subject to the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see http://www.boost.org
11 #ifndef BOOST_FUNCTION_BASE_HEADER
12 #define BOOST_FUNCTION_BASE_HEADER
18 #include <boost/config.hpp>
19 #include <boost/assert.hpp>
20 #include <boost/integer.hpp>
21 #include <boost/type_index.hpp>
22 #include <boost/type_traits/has_trivial_copy.hpp>
23 #include <boost/type_traits/has_trivial_destructor.hpp>
24 #include <boost/type_traits/is_const.hpp>
25 #include <boost/type_traits/is_integral.hpp>
26 #include <boost/type_traits/is_volatile.hpp>
27 #include <boost/type_traits/composite_traits.hpp>
28 #include <boost/ref.hpp>
29 #include <boost/mpl/if.hpp>
30 #include <boost/detail/workaround.hpp>
31 #include <boost/type_traits/alignment_of.hpp>
32 #ifndef BOOST_NO_SFINAE
33 # include "boost/utility/enable_if.hpp"
35 # include "boost/mpl/bool.hpp"
37 #include <boost/function_equal.hpp>
38 #include <boost/function/function_fwd.hpp>
40 #if defined(BOOST_MSVC)
41 # pragma warning( push )
42 # pragma warning( disable : 4793 ) // complaint about native code generation
43 # pragma warning( disable : 4127 ) // "conditional expression is constant"
46 #if defined(__ICL) && __ICL <= 600 || defined(__MWERKS__) && __MWERKS__ < 0x2406 && !defined(BOOST_STRICT_CONFIG)
47 # define BOOST_FUNCTION_TARGET_FIX(x) x
49 # define BOOST_FUNCTION_TARGET_FIX(x)
52 # define BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor,Type) \
53 typename ::boost::enable_if_c< \
54 !(::boost::is_integral<Functor>::value), \
63 * A buffer used to store small function objects in
64 * boost::function. It is a union containing function pointers,
65 * object pointers, and a structure that resembles a bound
66 * member function pointer.
68 union function_buffer_members
70 // For pointers to function objects
71 typedef void* obj_ptr_t;
72 mutable obj_ptr_t obj_ptr;
74 // For pointers to std::type_info objects
76 // (get_functor_type_tag, check_functor_type_tag).
77 const boost::typeindex::type_info* type;
79 // Whether the type is const-qualified.
81 // Whether the type is volatile-qualified.
82 bool volatile_qualified;
85 // For function pointers of all kinds
86 typedef void (*func_ptr_t)();
87 mutable func_ptr_t func_ptr;
89 // For bound member pointers
90 struct bound_memfunc_ptr_t {
91 void (X::*memfunc_ptr)(int);
95 // For references to function objects. We explicitly keep
96 // track of the cv-qualifiers on the object referenced.
98 mutable void* obj_ptr;
99 bool is_const_qualified;
100 bool is_volatile_qualified;
104 union function_buffer
106 // Type-specific union members
107 mutable function_buffer_members members;
109 // To relax aliasing constraints
110 mutable char data[sizeof(function_buffer_members)];
114 * The unusable class is a placeholder for unused function arguments
115 * It is also completely unusable except that it constructable from
116 * anything. This helps compilers without partial specialization to
117 * handle Boost.Function objects returning void.
122 template<typename T> unusable(const T&) {}
125 /* Determine the return type. This supports compilers that do not support
126 * void returns or partial specialization by silently changing the return
127 * type to "unusable".
129 template<typename T> struct function_return_type { typedef T type; };
132 struct function_return_type<void>
134 typedef unusable type;
137 // The operation type to perform on the given functor/function pointer
138 enum functor_manager_operation_type {
142 check_functor_type_tag,
146 // Tags used to decide between different types of functions
147 struct function_ptr_tag {};
148 struct function_obj_tag {};
149 struct member_ptr_tag {};
150 struct function_obj_ref_tag {};
153 class get_function_tag
155 typedef typename mpl::if_c<(is_pointer<F>::value),
157 function_obj_tag>::type ptr_or_obj_tag;
159 typedef typename mpl::if_c<(is_member_pointer<F>::value),
161 ptr_or_obj_tag>::type ptr_or_obj_or_mem_tag;
163 typedef typename mpl::if_c<(is_reference_wrapper<F>::value),
164 function_obj_ref_tag,
165 ptr_or_obj_or_mem_tag>::type or_ref_tag;
168 typedef or_ref_tag type;
171 // The trivial manager does nothing but return the same pointer (if we
172 // are cloning) or return the null pointer (if we are deleting).
174 struct reference_manager
177 manage(const function_buffer& in_buffer, function_buffer& out_buffer,
178 functor_manager_operation_type op)
181 case clone_functor_tag:
182 out_buffer.members.obj_ref = in_buffer.members.obj_ref;
185 case move_functor_tag:
186 out_buffer.members.obj_ref = in_buffer.members.obj_ref;
187 in_buffer.members.obj_ref.obj_ptr = 0;
190 case destroy_functor_tag:
191 out_buffer.members.obj_ref.obj_ptr = 0;
194 case check_functor_type_tag:
196 // Check whether we have the same type. We can add
197 // cv-qualifiers, but we can't take them away.
198 if (*out_buffer.members.type.type == boost::typeindex::type_id<F>()
199 && (!in_buffer.members.obj_ref.is_const_qualified
200 || out_buffer.members.type.const_qualified)
201 && (!in_buffer.members.obj_ref.is_volatile_qualified
202 || out_buffer.members.type.volatile_qualified))
203 out_buffer.members.obj_ptr = in_buffer.members.obj_ref.obj_ptr;
205 out_buffer.members.obj_ptr = 0;
209 case get_functor_type_tag:
210 out_buffer.members.type.type = &boost::typeindex::type_id<F>().type_info();
211 out_buffer.members.type.const_qualified = in_buffer.members.obj_ref.is_const_qualified;
212 out_buffer.members.type.volatile_qualified = in_buffer.members.obj_ref.is_volatile_qualified;
219 * Determine if boost::function can use the small-object
220 * optimization with the function object type F.
223 struct function_allows_small_object_optimization
225 BOOST_STATIC_CONSTANT
227 value = ((sizeof(F) <= sizeof(function_buffer) &&
228 (alignment_of<function_buffer>::value
229 % alignment_of<F>::value == 0))));
232 template <typename F,typename A>
233 struct functor_wrapper: public F, public A
235 functor_wrapper( F f, A a ):
241 functor_wrapper(const functor_wrapper& f) :
242 F(static_cast<const F&>(f)),
243 A(static_cast<const A&>(f))
249 * The functor_manager class contains a static function "manage" which
250 * can clone or destroy the given function/function object pointer.
252 template<typename Functor>
253 struct functor_manager_common
255 typedef Functor functor_type;
259 manage_ptr(const function_buffer& in_buffer, function_buffer& out_buffer,
260 functor_manager_operation_type op)
262 if (op == clone_functor_tag)
263 out_buffer.members.func_ptr = in_buffer.members.func_ptr;
264 else if (op == move_functor_tag) {
265 out_buffer.members.func_ptr = in_buffer.members.func_ptr;
266 in_buffer.members.func_ptr = 0;
267 } else if (op == destroy_functor_tag)
268 out_buffer.members.func_ptr = 0;
269 else if (op == check_functor_type_tag) {
270 if (*out_buffer.members.type.type == boost::typeindex::type_id<Functor>())
271 out_buffer.members.obj_ptr = &in_buffer.members.func_ptr;
273 out_buffer.members.obj_ptr = 0;
274 } else /* op == get_functor_type_tag */ {
275 out_buffer.members.type.type = &boost::typeindex::type_id<Functor>().type_info();
276 out_buffer.members.type.const_qualified = false;
277 out_buffer.members.type.volatile_qualified = false;
281 // Function objects that fit in the small-object buffer.
283 manage_small(const function_buffer& in_buffer, function_buffer& out_buffer,
284 functor_manager_operation_type op)
286 if (op == clone_functor_tag || op == move_functor_tag) {
287 const functor_type* in_functor =
288 reinterpret_cast<const functor_type*>(in_buffer.data);
289 new (reinterpret_cast<void*>(out_buffer.data)) functor_type(*in_functor);
291 if (op == move_functor_tag) {
292 functor_type* f = reinterpret_cast<functor_type*>(in_buffer.data);
293 (void)f; // suppress warning about the value of f not being used (MSVC)
296 } else if (op == destroy_functor_tag) {
297 // Some compilers (Borland, vc6, ...) are unhappy with ~functor_type.
298 functor_type* f = reinterpret_cast<functor_type*>(out_buffer.data);
299 (void)f; // suppress warning about the value of f not being used (MSVC)
301 } else if (op == check_functor_type_tag) {
302 if (*out_buffer.members.type.type == boost::typeindex::type_id<Functor>())
303 out_buffer.members.obj_ptr = in_buffer.data;
305 out_buffer.members.obj_ptr = 0;
306 } else /* op == get_functor_type_tag */ {
307 out_buffer.members.type.type = &boost::typeindex::type_id<Functor>().type_info();
308 out_buffer.members.type.const_qualified = false;
309 out_buffer.members.type.volatile_qualified = false;
314 template<typename Functor>
315 struct functor_manager
318 typedef Functor functor_type;
322 manager(const function_buffer& in_buffer, function_buffer& out_buffer,
323 functor_manager_operation_type op, function_ptr_tag)
325 functor_manager_common<Functor>::manage_ptr(in_buffer,out_buffer,op);
328 // Function objects that fit in the small-object buffer.
330 manager(const function_buffer& in_buffer, function_buffer& out_buffer,
331 functor_manager_operation_type op, mpl::true_)
333 functor_manager_common<Functor>::manage_small(in_buffer,out_buffer,op);
336 // Function objects that require heap allocation
338 manager(const function_buffer& in_buffer, function_buffer& out_buffer,
339 functor_manager_operation_type op, mpl::false_)
341 if (op == clone_functor_tag) {
343 // GCC 2.95.3 gets the CV qualifiers wrong here, so we
344 // can't do the static_cast that we should do.
345 // jewillco: Changing this to static_cast because GCC 2.95.3 is
347 const functor_type* f =
348 static_cast<const functor_type*>(in_buffer.members.obj_ptr);
349 functor_type* new_f = new functor_type(*f);
350 out_buffer.members.obj_ptr = new_f;
351 } else if (op == move_functor_tag) {
352 out_buffer.members.obj_ptr = in_buffer.members.obj_ptr;
353 in_buffer.members.obj_ptr = 0;
354 } else if (op == destroy_functor_tag) {
355 /* Cast from the void pointer to the functor pointer type */
357 static_cast<functor_type*>(out_buffer.members.obj_ptr);
359 out_buffer.members.obj_ptr = 0;
360 } else if (op == check_functor_type_tag) {
361 if (*out_buffer.members.type.type == boost::typeindex::type_id<Functor>())
362 out_buffer.members.obj_ptr = in_buffer.members.obj_ptr;
364 out_buffer.members.obj_ptr = 0;
365 } else /* op == get_functor_type_tag */ {
366 out_buffer.members.type.type = &boost::typeindex::type_id<Functor>().type_info();
367 out_buffer.members.type.const_qualified = false;
368 out_buffer.members.type.volatile_qualified = false;
372 // For function objects, we determine whether the function
373 // object can use the small-object optimization buffer or
374 // whether we need to allocate it on the heap.
376 manager(const function_buffer& in_buffer, function_buffer& out_buffer,
377 functor_manager_operation_type op, function_obj_tag)
379 manager(in_buffer, out_buffer, op,
380 mpl::bool_<(function_allows_small_object_optimization<functor_type>::value)>());
383 // For member pointers, we use the small-object optimization buffer.
385 manager(const function_buffer& in_buffer, function_buffer& out_buffer,
386 functor_manager_operation_type op, member_ptr_tag)
388 manager(in_buffer, out_buffer, op, mpl::true_());
392 /* Dispatch to an appropriate manager based on whether we have a
393 function pointer or a function object pointer. */
395 manage(const function_buffer& in_buffer, function_buffer& out_buffer,
396 functor_manager_operation_type op)
398 typedef typename get_function_tag<functor_type>::type tag_type;
400 case get_functor_type_tag:
401 out_buffer.members.type.type = &boost::typeindex::type_id<functor_type>().type_info();
402 out_buffer.members.type.const_qualified = false;
403 out_buffer.members.type.volatile_qualified = false;
407 manager(in_buffer, out_buffer, op, tag_type());
413 template<typename Functor, typename Allocator>
414 struct functor_manager_a
417 typedef Functor functor_type;
421 manager(const function_buffer& in_buffer, function_buffer& out_buffer,
422 functor_manager_operation_type op, function_ptr_tag)
424 functor_manager_common<Functor>::manage_ptr(in_buffer,out_buffer,op);
427 // Function objects that fit in the small-object buffer.
429 manager(const function_buffer& in_buffer, function_buffer& out_buffer,
430 functor_manager_operation_type op, mpl::true_)
432 functor_manager_common<Functor>::manage_small(in_buffer,out_buffer,op);
435 // Function objects that require heap allocation
437 manager(const function_buffer& in_buffer, function_buffer& out_buffer,
438 functor_manager_operation_type op, mpl::false_)
440 typedef functor_wrapper<Functor,Allocator> functor_wrapper_type;
441 typedef typename Allocator::template rebind<functor_wrapper_type>::other
442 wrapper_allocator_type;
443 typedef typename wrapper_allocator_type::pointer wrapper_allocator_pointer_type;
445 if (op == clone_functor_tag) {
447 // GCC 2.95.3 gets the CV qualifiers wrong here, so we
448 // can't do the static_cast that we should do.
449 const functor_wrapper_type* f =
450 static_cast<const functor_wrapper_type*>(in_buffer.members.obj_ptr);
451 wrapper_allocator_type wrapper_allocator(static_cast<Allocator const &>(*f));
452 wrapper_allocator_pointer_type copy = wrapper_allocator.allocate(1);
453 wrapper_allocator.construct(copy, *f);
455 // Get back to the original pointer type
456 functor_wrapper_type* new_f = static_cast<functor_wrapper_type*>(copy);
457 out_buffer.members.obj_ptr = new_f;
458 } else if (op == move_functor_tag) {
459 out_buffer.members.obj_ptr = in_buffer.members.obj_ptr;
460 in_buffer.members.obj_ptr = 0;
461 } else if (op == destroy_functor_tag) {
462 /* Cast from the void pointer to the functor_wrapper_type */
463 functor_wrapper_type* victim =
464 static_cast<functor_wrapper_type*>(in_buffer.members.obj_ptr);
465 wrapper_allocator_type wrapper_allocator(static_cast<Allocator const &>(*victim));
466 wrapper_allocator.destroy(victim);
467 wrapper_allocator.deallocate(victim,1);
468 out_buffer.members.obj_ptr = 0;
469 } else if (op == check_functor_type_tag) {
470 if (*out_buffer.members.type.type == boost::typeindex::type_id<Functor>())
471 out_buffer.members.obj_ptr = in_buffer.members.obj_ptr;
473 out_buffer.members.obj_ptr = 0;
474 } else /* op == get_functor_type_tag */ {
475 out_buffer.members.type.type = &boost::typeindex::type_id<Functor>().type_info();
476 out_buffer.members.type.const_qualified = false;
477 out_buffer.members.type.volatile_qualified = false;
481 // For function objects, we determine whether the function
482 // object can use the small-object optimization buffer or
483 // whether we need to allocate it on the heap.
485 manager(const function_buffer& in_buffer, function_buffer& out_buffer,
486 functor_manager_operation_type op, function_obj_tag)
488 manager(in_buffer, out_buffer, op,
489 mpl::bool_<(function_allows_small_object_optimization<functor_type>::value)>());
493 /* Dispatch to an appropriate manager based on whether we have a
494 function pointer or a function object pointer. */
496 manage(const function_buffer& in_buffer, function_buffer& out_buffer,
497 functor_manager_operation_type op)
499 typedef typename get_function_tag<functor_type>::type tag_type;
501 case get_functor_type_tag:
502 out_buffer.members.type.type = &boost::typeindex::type_id<functor_type>().type_info();
503 out_buffer.members.type.const_qualified = false;
504 out_buffer.members.type.volatile_qualified = false;
508 manager(in_buffer, out_buffer, op, tag_type());
514 // A type that is only used for comparisons against zero
515 struct useless_clear_type {};
517 #ifdef BOOST_NO_SFINAE
518 // These routines perform comparisons between a Boost.Function
519 // object and an arbitrary function object (when the last
520 // parameter is mpl::bool_<false>) or against zero (when the
521 // last parameter is mpl::bool_<true>). They are only necessary
522 // for compilers that don't support SFINAE.
523 template<typename Function, typename Functor>
525 compare_equal(const Function& f, const Functor&, int, mpl::bool_<true>)
526 { return f.empty(); }
528 template<typename Function, typename Functor>
530 compare_not_equal(const Function& f, const Functor&, int,
532 { return !f.empty(); }
534 template<typename Function, typename Functor>
536 compare_equal(const Function& f, const Functor& g, long,
539 if (const Functor* fp = f.template target<Functor>())
540 return function_equal(*fp, g);
544 template<typename Function, typename Functor>
546 compare_equal(const Function& f, const reference_wrapper<Functor>& g,
547 int, mpl::bool_<false>)
549 if (const Functor* fp = f.template target<Functor>())
550 return fp == g.get_pointer();
554 template<typename Function, typename Functor>
556 compare_not_equal(const Function& f, const Functor& g, long,
559 if (const Functor* fp = f.template target<Functor>())
560 return !function_equal(*fp, g);
564 template<typename Function, typename Functor>
566 compare_not_equal(const Function& f,
567 const reference_wrapper<Functor>& g, int,
570 if (const Functor* fp = f.template target<Functor>())
571 return fp != g.get_pointer();
574 #endif // BOOST_NO_SFINAE
577 * Stores the "manager" portion of the vtable for a
578 * boost::function object.
582 void (*manager)(const function_buffer& in_buffer,
583 function_buffer& out_buffer,
584 functor_manager_operation_type op);
586 } // end namespace function
587 } // end namespace detail
590 * The function_base class contains the basic elements needed for the
591 * function1, function2, function3, etc. classes. It is common to all
592 * functions (and as such can be used to tell if we have one of the
593 * functionN objects).
598 function_base() : vtable(0) { }
600 /** Determine if the function is empty (i.e., has no target). */
601 bool empty() const { return !vtable; }
603 /** Retrieve the type of the stored function object, or type_id<void>()
605 const boost::typeindex::type_info& target_type() const
607 if (!vtable) return boost::typeindex::type_id<void>().type_info();
609 detail::function::function_buffer type;
610 get_vtable()->manager(functor, type, detail::function::get_functor_type_tag);
611 return *type.members.type.type;
614 template<typename Functor>
617 if (!vtable) return 0;
619 detail::function::function_buffer type_result;
620 type_result.members.type.type = &boost::typeindex::type_id<Functor>().type_info();
621 type_result.members.type.const_qualified = is_const<Functor>::value;
622 type_result.members.type.volatile_qualified = is_volatile<Functor>::value;
623 get_vtable()->manager(functor, type_result,
624 detail::function::check_functor_type_tag);
625 return static_cast<Functor*>(type_result.members.obj_ptr);
628 template<typename Functor>
629 const Functor* target() const
631 if (!vtable) return 0;
633 detail::function::function_buffer type_result;
634 type_result.members.type.type = &boost::typeindex::type_id<Functor>().type_info();
635 type_result.members.type.const_qualified = true;
636 type_result.members.type.volatile_qualified = is_volatile<Functor>::value;
637 get_vtable()->manager(functor, type_result,
638 detail::function::check_functor_type_tag);
639 // GCC 2.95.3 gets the CV qualifiers wrong here, so we
640 // can't do the static_cast that we should do.
641 return static_cast<const Functor*>(type_result.members.obj_ptr);
645 bool contains(const F& f) const
647 if (const F* fp = this->template target<F>())
649 return function_equal(*fp, f);
655 #if defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3
656 // GCC 3.3 and newer cannot copy with the global operator==, due to
657 // problems with instantiation of function return types before it
658 // has been verified that the argument types match up.
659 template<typename Functor>
660 BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
661 operator==(Functor g) const
663 if (const Functor* fp = target<Functor>())
664 return function_equal(*fp, g);
668 template<typename Functor>
669 BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
670 operator!=(Functor g) const
672 if (const Functor* fp = target<Functor>())
673 return !function_equal(*fp, g);
678 public: // should be protected, but GCC 2.95.3 will fail to allow access
679 detail::function::vtable_base* get_vtable() const {
680 return reinterpret_cast<detail::function::vtable_base*>(
681 reinterpret_cast<std::size_t>(vtable) & ~static_cast<std::size_t>(0x01));
684 bool has_trivial_copy_and_destroy() const {
685 return reinterpret_cast<std::size_t>(vtable) & 0x01;
688 detail::function::vtable_base* vtable;
689 mutable detail::function::function_buffer functor;
693 * The bad_function_call exception class is thrown when a boost::function
696 class bad_function_call : public std::runtime_error
699 bad_function_call() : std::runtime_error("call to empty boost::function") {}
702 #ifndef BOOST_NO_SFINAE
703 inline bool operator==(const function_base& f,
704 detail::function::useless_clear_type*)
709 inline bool operator!=(const function_base& f,
710 detail::function::useless_clear_type*)
715 inline bool operator==(detail::function::useless_clear_type*,
716 const function_base& f)
721 inline bool operator!=(detail::function::useless_clear_type*,
722 const function_base& f)
728 #ifdef BOOST_NO_SFINAE
729 // Comparisons between boost::function objects and arbitrary function objects
730 template<typename Functor>
731 inline bool operator==(const function_base& f, Functor g)
733 typedef mpl::bool_<(is_integral<Functor>::value)> integral;
734 return detail::function::compare_equal(f, g, 0, integral());
737 template<typename Functor>
738 inline bool operator==(Functor g, const function_base& f)
740 typedef mpl::bool_<(is_integral<Functor>::value)> integral;
741 return detail::function::compare_equal(f, g, 0, integral());
744 template<typename Functor>
745 inline bool operator!=(const function_base& f, Functor g)
747 typedef mpl::bool_<(is_integral<Functor>::value)> integral;
748 return detail::function::compare_not_equal(f, g, 0, integral());
751 template<typename Functor>
752 inline bool operator!=(Functor g, const function_base& f)
754 typedef mpl::bool_<(is_integral<Functor>::value)> integral;
755 return detail::function::compare_not_equal(f, g, 0, integral());
759 # if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
760 // Comparisons between boost::function objects and arbitrary function
761 // objects. GCC 3.3 and before has an obnoxious bug that prevents this
763 template<typename Functor>
764 BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
765 operator==(const function_base& f, Functor g)
767 if (const Functor* fp = f.template target<Functor>())
768 return function_equal(*fp, g);
772 template<typename Functor>
773 BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
774 operator==(Functor g, const function_base& f)
776 if (const Functor* fp = f.template target<Functor>())
777 return function_equal(g, *fp);
781 template<typename Functor>
782 BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
783 operator!=(const function_base& f, Functor g)
785 if (const Functor* fp = f.template target<Functor>())
786 return !function_equal(*fp, g);
790 template<typename Functor>
791 BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
792 operator!=(Functor g, const function_base& f)
794 if (const Functor* fp = f.template target<Functor>())
795 return !function_equal(g, *fp);
800 template<typename Functor>
801 BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
802 operator==(const function_base& f, reference_wrapper<Functor> g)
804 if (const Functor* fp = f.template target<Functor>())
805 return fp == g.get_pointer();
809 template<typename Functor>
810 BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
811 operator==(reference_wrapper<Functor> g, const function_base& f)
813 if (const Functor* fp = f.template target<Functor>())
814 return g.get_pointer() == fp;
818 template<typename Functor>
819 BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
820 operator!=(const function_base& f, reference_wrapper<Functor> g)
822 if (const Functor* fp = f.template target<Functor>())
823 return fp != g.get_pointer();
827 template<typename Functor>
828 BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
829 operator!=(reference_wrapper<Functor> g, const function_base& f)
831 if (const Functor* fp = f.template target<Functor>())
832 return g.get_pointer() != fp;
836 #endif // Compiler supporting SFINAE
840 inline bool has_empty_target(const function_base* f)
845 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
846 inline bool has_empty_target(const void*)
851 inline bool has_empty_target(...)
856 } // end namespace function
857 } // end namespace detail
858 } // end namespace boost
860 #undef BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL
862 #if defined(BOOST_MSVC)
863 # pragma warning( pop )
866 #endif // BOOST_FUNCTION_BASE_HEADER