MCPcopy Create free account
hub / github.com/ablab/spades / function_base

Class function_base

ext/include/boost/function/function_base.hpp:606–715  ·  view source on GitHub ↗

* The function_base class contains the basic elements needed for the * function1, function2, function3, etc. classes. It is common to all * functions (and as such can be used to tell if we have one of the * functionN objects). */

Source from the content-addressed store, hash-verified

604 * functionN objects).
605 */
606class function_base
607{
608public:
609 function_base() : vtable(0) { }
610
611 /** Determine if the function is empty (i.e., has no target). */
612 bool empty() const { return !vtable; }
613
614 /** Retrieve the type of the stored function object, or type_id<void>()
615 if this is empty. */
616 const boost::core::typeinfo& target_type() const
617 {
618 if (!vtable) return BOOST_CORE_TYPEID(void);
619
620 detail::function::function_buffer type;
621 get_vtable()->manager(functor, type, detail::function::get_functor_type_tag);
622 return *type.members.type.type;
623 }
624
625 template<typename Functor>
626 Functor* target()
627 {
628 if (!vtable) return 0;
629
630 detail::function::function_buffer type_result;
631 type_result.members.type.type = &BOOST_CORE_TYPEID(Functor);
632 type_result.members.type.const_qualified = is_const<Functor>::value;
633 type_result.members.type.volatile_qualified = is_volatile<Functor>::value;
634 get_vtable()->manager(functor, type_result,
635 detail::function::check_functor_type_tag);
636 return static_cast<Functor*>(type_result.members.obj_ptr);
637 }
638
639 template<typename Functor>
640 const Functor* target() const
641 {
642 if (!vtable) return 0;
643
644 detail::function::function_buffer type_result;
645 type_result.members.type.type = &BOOST_CORE_TYPEID(Functor);
646 type_result.members.type.const_qualified = true;
647 type_result.members.type.volatile_qualified = is_volatile<Functor>::value;
648 get_vtable()->manager(functor, type_result,
649 detail::function::check_functor_type_tag);
650 // GCC 2.95.3 gets the CV qualifiers wrong here, so we
651 // can't do the static_cast that we should do.
652 return static_cast<const Functor*>(type_result.members.obj_ptr);
653 }
654
655 template<typename F>
656 typename boost::enable_if_< !boost::is_function<F>::value, bool >::type
657 contains(const F& f) const
658 {
659 if (const F* fp = this->template target<F>())
660 {
661 return function_equal(*fp, f);
662 } else {
663 return false;

Callers

nothing calls this directly

Calls 1

managerMethod · 0.45

Tested by

no test coverage detected