Removed function_cast() and .target_type()

[SVN r11443]
This commit is contained in:
Douglas Gregor
2001-10-25 20:56:14 +00:00
parent d7ac137669
commit 3c5579ccbc

View File

@ -46,8 +46,6 @@ namespace boost {
virtual R call(BOOST_FUNCTION_PARMS) const = 0;
virtual BOOST_FUNCTION_INVOKER_BASE* clone() const = 0;
virtual void destroy(BOOST_FUNCTION_INVOKER_BASE*) = 0;
virtual const std::type_info& type() const = 0;
virtual any_pointer pointer() const = 0;
};
#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
@ -115,16 +113,6 @@ namespace boost {
# endif // BOOST_NO_STD_ALLOCATOR
}
virtual const std::type_info& type() const
{
return typeid(FunctionPtr);
}
virtual any_pointer pointer() const
{
return any_pointer(reinterpret_cast<void (*)()>(function_ptr));
}
private:
mutable FunctionPtr function_ptr;
#else
@ -202,16 +190,6 @@ namespace boost {
# endif // BOOST_NO_STD_ALLOCATOR
}
virtual const std::type_info& type() const
{
return typeid(FunctionPtr);
}
virtual any_pointer pointer() const
{
return any_pointer(reinterpret_cast<void (*)()>(function_ptr));
}
private:
mutable FunctionPtr function_ptr;
# else
@ -290,16 +268,6 @@ namespace boost {
#endif // BOOST_NO_STD_ALLOCATOR
}
virtual const std::type_info& type() const
{
return typeid(FunctionObj);
}
virtual any_pointer pointer() const
{
return any_pointer(&function_obj);
}
private:
mutable FunctionObj function_obj;
#else
@ -378,16 +346,6 @@ namespace boost {
# endif // BOOST_NO_STD_ALLOCATOR
}
virtual const std::type_info& type() const
{
return typeid(FunctionObj);
}
virtual any_pointer pointer() const
{
return any_pointer(&function_obj);
}
private:
mutable FunctionObj function_obj;
# else
@ -643,69 +601,7 @@ namespace boost {
#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
}
const std::type_info& target_type() const
{
if (this->empty())
return typeid(void);
else {
#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
impl_type* i = reinterpret_cast<impl_type*>(impl);
return i->type();
#else
detail::function::any_pointer p =
manager(functor, detail::function::retrieve_type_info);
return *static_cast<const std::type_info*>(p.const_obj_ptr);
#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
}
}
template<typename To>
To& cast(To* dummy = 0)
{
assert(typeid(To) != typeid(void));
assert(typeid(To) == this->target_type());
typedef typename detail::function::get_function_tag<To>::type tag;
#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
impl_type* i = reinterpret_cast<impl_type*>(impl);
return cast_helper(i->pointer(), tag(), dummy);
#else
return cast_helper(functor, tag(), dummy);
#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
}
template<typename To>
const To& cast(To* dummy = 0) const
{
assert(typeid(To) != typeid(void));
assert(typeid(To) == this->target_type());
typedef typename detail::function::get_function_tag<To>::type tag;
#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
impl_type* i = reinterpret_cast<impl_type*>(impl);
return cast_helper(i->pointer(), tag(), dummy);
#else
return cast_helper(functor, tag(), dummy);
#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
}
private:
template<typename To>
To& cast_helper(detail::function::any_pointer p,
detail::function::function_ptr_tag,
To* = 0) const
{
return reinterpret_cast<To>(p.func_ptr);
}
template<typename To>
To& cast_helper(detail::function::any_pointer p,
detail::function::function_obj_tag,
To* = 0) const
{
return *static_cast<To*>(p.obj_ptr);
}
void assign_to_own(const BOOST_FUNCTION_FUNCTION& f)
{
if (!f.empty()) {
@ -838,36 +734,6 @@ namespace boost {
>& f2)
{
f1.swap(f2);
}
template<typename To, typename R
BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Policy, typename Mixin, typename Allocator>
inline To& function_cast(BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Policy,
Mixin,
Allocator
>& f,
To* dummy = 0)
{
return f.cast(dummy);
}
template<typename To, typename R
BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS ,
typename Policy, typename Mixin, typename Allocator>
inline const To& function_cast(const BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS ,
Policy,
Mixin,
Allocator
>& f,
To* dummy = 0)
{
return f.cast(dummy);
}
}