I've been looking through some real code to see where we pactically could 
benefit from MPL and think I've found a nice one :

If one wants to integrate generic programming inside a strong OO designed 
program, you might want to try to downcast a pointer to a base-class to all 
possible derived-classes and once you found the right derived class (and got 
all the type information you need again) you can restart using templates and 
a real generic approach. However to do this 'trick ' in a scalable manner, 
you need to try all downcasts based on a compile-time list of all derived 
classes instead of hardcoding the list like :

downcast(base_class* base) {
  derived1 d1 = dynamic_cast< derived1* >( base ) ;
  if ( d1 ) foo< derived1 >( d1 ) ;

  derived2 d2 = dynamic_cast< derived2* >( base ) ;
  if ( d2 ) foo< derived2 >( d2 ) ;
}

This might seem like bad design but is a very helpfull construct to avoid 
performance penalties from a to much OO oriented approach by implementing 
performance critical pieces using generic programming. Therefor I think it 
can appeal to many people that are coming from OO and start looking at 
generic programming.

toon
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to