I have m ints and n floats and I want to iterate over them in one loop. In order to do so, I can think of two possible ways but I don't know if they are actually feasible:
Ideally I want to store the m+n numbers in one array (e.g. in one std::vector), is there a way (a container, or by means of polymorphism) that I could do this?
If I must store the ints and floats in two arrays, is there (or how to write) an iterator that can iterate the two arrays in on loop?
Any idea is welcome!
anyto store them but you'd need to have a marker variable to know where to start reading ints and where to start reading floats, just placing them in two arrays would be simpler.template <typename T> void iterate_array(T *first, T *last);, then you just call the function twice with different arguments:iterate_array(int_arr, int_arr + size); iterate_array(float_arr, float_arr + size);std::pair