Is it possible to dynamically cast a stl::list of derived pointers to a list of base pointers?

I have these two lists

1
2
	list <PrivateShoutOut*> allPrivateShoutOutsList;
	list<PublicShoutOut*> allPublicShoutOutsList;


PrivateShoutOut and PublicShoutOut both inherit from ShoutOut, which is abstract.

I want to be able to pass either of these lists to a function with this header

void System::linkShoutOutsToAccounts(list<ShoutOut*>& listOfShoutOuts)

Is that possible with dynamic casting?

I have also tried casting an iterator so I could pass casted iterators to the function instead

1
2
3
4
5
6
7
8
9
10
	list<PublicShoutOut*>::iterator start, finish;
	//set the iterators to the beginning and end of the allPrivateShoutOutsList
	start = allPublicShoutOutsList.begin();
	finish = allPublicShoutOutsList.end();



	list<ShoutOut*>::iterator* convertedIterator;

	convertedIterator = dynamic_cast<list<ShoutOut*>::iterator*>(&start);



As far as I can tell it isn't possible to do this. I get

'std::_List_iterator<_Mylist>' is not a polymorphic type
Topic archived. No new replies allowed.