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

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -