Darn. I meant to put that in the message. Isn't email supposed to be psychic? I can't change the base class, hence the problem. It's a very wide hierarchy for a framework that I can't change. Thanks for the suggestion, though. ...Duane --- At Tue, 4 Oct 2005 14:47:29 -0700, Sohail Somani wrote:
Is there some trouble with defining:
class Base { virtual void some_function() = 0; };
???
I can understand the void f() entry point for C callbacks but you can use C++ to do the work for you. Unless I'm missing something.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Duane Murphy Sent: Tuesday, October 04, 2005 2:38 PM To: Boost Users Subject: [Boost-users] Type List Iteration?
How do I iterate over a type list and call a function? MPL?
I have a base class BASE that has several subclasses A, B, C that have special capabilities, but no way to identify those capabilities aside from the type.
I would like to determine if an object of type BASE is also of one of the special subclasses:
ie void f( BASE* base) { if ( dynamic_cast< A* >( base ) != NULL ) { some_function( dynamic_cast< A* >( base ) ); } else if ( dynamic_cast< B* >( base ) != NULL ) { some_function( dynamic_cast< B* >( base ) ); } else if ( dynamic_cast< C* >( base ) != NULL ) { some_function( dynamic_cast< C* >( base ) ); } }
I think you can see why I'd like a type list iterator solution to this.
I have arranged for the some_function to be a template as well to make things easier.
What I am looking for is the equivalent of find_if() but for types and done at run time. I looked over MPL, but MPL seems to apply at compile time without a door to the run time world. :-)
Thanks for your helpful tips!
...Duane