I'm not sure I understand your question.
Is boost::variantwhat you are looking for? This will allow you to store items with different types in one container.
Code example (not tested):
typedef boost::variant <
std::vector<int>,
std::vector<char>,
std::vector<float>
> VectorOfIntCharOrFloat;
std::list<VectorOfIntCharOrFloat> vec;
and then iterate over it / access elements as:
std::list<VectorOfIntCharOrFloat>::iterator itr = vec.begin();
while(itr != vec.end()) {
if(std::vector<int> * i = boost::get<std::vector<int> >(itr)) {
std::cout << "int vector"<< std::endl;
} else if(std::vector<float> * f = boost::get<std::vector<float> >(itr)) {
std::cout << "float vector" << std::endl;
} else if(std::vector<char> * c = boost::get<std::vector<char> >(itr)){
std::cout << "char vector" << std::endl;
}
++itr;
}
source
share