c++ - read sequence of hex values from ifstream using std::copy -
consider file containing sequence of integers expressed in hex notation. can stream them in this:
using namespace std; ifstream infile(fname); unsigned int i; vector<unsigned int> vals; while (infile >> std::hex >> i){ vals.push_back(i); }
what if want same thing istream_iterator
?
/// borks on hex: copy(istream_iterator<unsigned int>(infile), istream_iterator<unsigned int>(), back_inserter(ref_data));
is there way tell istream_iterator
how assume hex notation?
same way:
copy(istream_iterator<unsigned int>(infile >> std::hex), istream_iterator<unsigned int>(), back_inserter(ref_data));
Comments
Post a Comment