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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -