Say we have a base class green and such hieraachy tree:

We have a list greenList filled whith all classes red, blue etc looking like green. We do not create this list we are given it filled with data. We now want to create lists for red, yellow etc classes. We do have headers for red etc classes, we do not want to have getType inside green class.
How to sort that list greenList into lists like redList, yellowList etc in C++03 (using boost)?
If they are pointers, use dynamic_cast and check the return value; if they are refs use dynamic cast inside a try/catch block.