In order to use vectors you need to explicitly specify the type of objects that they will be holding.In your case it will be boost::shared_ptr
. I also understand that you want to store dumb pointers in that container. You probably mean raw pointers.As mentioned earlier your container can primarily store one type however there are exceptions for instance the types are related via inheritance or another mechanism (such as serialization) for which some explicit down-casting would be required when you attempt to use those objects or the type is a generic type. Never the less. Here is another approach. You don't need a vector that stores both a smart pointer and a raw pointer since you could always obtain a raw/dumb pointer from a smart pointer. Your best approach is to create a vector like this
std::vector<boost::shared_ptr<foo>> vec;
The above creates a vector that will store shared pointers to foo.
Then when ever you have a shared pointer as such
boost::shared_ptr<foo> foo_ptr(new foo());
You can do something like this
vec.push_back(foo_ptr)
When you need the dumb pointer you could do this
foo* f = vec[0].get();
I read your update in which you stated
... it seems that the container must indeed be declared to take smart
pointers, it can't be made to take either smart or dumb pointers.
You should understand that boost::shared_ptr<Type>
is a smart pointer.