|
Boost Users : |
Subject: [Boost-users] Problem with boost::any?
From: Germán Diago (germandiago_at_[hidden])
Date: 2009-01-12 13:50:21
Hello. I'm working with boost::any and shared_ptr.
I'm implementing a plugin system which uses registration from .so files
(under Linux).
The problem is that I have a factory function which returns boost::any. This
boost::any
object holds a pointer type. The problem is that when I try to get the
registered type back
to its real type through boost::any_cast, the cast always fails. If I
register this type in
the same executable as
the application, everything is ok, and I can cast back to its real type.I
have no idea why this happens:
template <class T>
struct ObjectFactory
{
boost::any operator()() const
{
typedef typename T::interface_type it;
it * t = new T();
return t;
}
};
#define REGISTER_EXTENSION_NODE(extensionpoint, ns) \
namespace { \
static const bool registeredextensionnode = \
::Gtk::Util::PluginsManager::instance().register_extension_node(#ns "::"
#extensionpoint, \
::Gtk::Util::detail::ExtensionNodeFactory<ns::extensionpoint>()); \
}
These are the implied parts of my application. If I use the macro from a
.so, it fails. If I use it from
the .exe, everything's ok. The registration part seems to work, I checked
the size of the containers
and so on, and the elements were inserted. Any help how could I solve this?
I've been trying to debug the problem for almost 4 hours with no luck.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net