Consider a file containing a sequence of integers expressed in hexadecimal notation. I can pass them as follows:
using namespace std;
ifstream infile(fname);
unsigned int i;
vector<unsigned int> vals;
while (infile >> std::hex >> i){
vals.push_back(i);
}
What if I want to do the same with istream_iterator?
copy(istream_iterator<unsigned int>(infile),
istream_iterator<unsigned int>(), back_inserter(ref_data));
Is there any way to tell istream_iteratorhow to use hexadecimal notation?
source
share