RE: [Boost-Users] Polymorphic containers (was Re: shared_ptr and inheritance)
From: rz0 [mailto:rz0@yahoo.com] Hi Bjorn
Thank you very much for the reply.
Unfortunately these classes are provided to me and as part of the requirements, I must be able to work with them. In re-thinking the problem, it seems that I'm in desperate need of a polymorphic container - i.e.:
Does boost have any polymorphic containers?
Thanks very much in advance.
I don't think that polymorphism is the cure - you'll always need to downcast
the pointer as the signatures differ. However, there is support in Boost for
what you're trying to do - through boost::any. Like I said before, the
solution will not be very clean, but it will work.
The code snippet below seems to do what you're asking for:
#include <iostream>
#include <algorithm>
#include <vector>
#include
Björn Karlsson wrote:
I don't think that polymorphism is the cure - you'll always need to downcast the pointer as the signatures differ. However, there is support in Boost for what you're trying to do - through boost::any. Like I said before, the solution will not be very clean, but it will work. The code snippet below seems to do what you're asking for:
Dear Björn Thank you very, very much for this example. I will attempt to implement it in my application. Thank you very much. Regards RZ _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
participants (2)
-
Björn Karlsson
-
Ramin Zahraie