
Steven Watanabe schrieb: [...]
Long answer:
Boost.Function stores a pointer, but it's a void pointer so it loses all type information. The type information is stored separately, using std::type_info. With this setup, there is no way to determine whether the type that you ask for is a base of the stored type. The only way to implement this is to create a class the inherits multiply from the stored type and a common base. This allows the use of dynamic_cast to cross cast. This unfortunately requires that it be possible to derive from the stored type, so built-ins become a special case. In addition, it makes the small buffer optimization difficult to implement seriously hurting performance even when this feature is not used.
Alright, I see. Thanks for your detailed explanation. I modified the approach so that I don't have to store (and therefore copy) the pointer to the boost::any any more. Probably not optimal either, but I have to see. For now, it works. Thanks Johannes