c++ - How to determine, what type do I have on input -
i've got iterator through undefined type:
(typename type::const_iterator haystackiterator = hayheap.begin(); haystackiterator != hayheap.end(); ++haystackiterator) { //some inner logic }
and nice, know type *haystackiterator
able modify inner logic pursuant information... there simple function make this?
if (*haystackiterator.isinstanceof(vector<string>){ //do } else if (*haystackiterator.isinstanceof(string){ //do else }
i can use these includes
:
#include <cctype> #include <iostream> #include <iomanip> #include <set> #include <list> #include <map> #include <vector> #include <queue> #include <string>
put inner logic in function, , overload function:
void innerlogic(vector<string> const& vec) { //do } void innerlogic(string const& str) { //do else } void loop() { (typename type::const_iterator haystackiterator = hayheap.begin(); haystackiterator != hayheap.end(); ++haystackiterator) { innerlogic(*haystackiterator); } }
Comments
Post a Comment