@dfalbel see my comment in the following code. You can also check c++ reference for std::istream_iterator.
std::ifstream input_stream("ivalue.pt");

// a. You need this line, otherwise istream_iterator will skip all the whitespace in the file
//     which will skip characters when reading "ivalue.pt"
// b. try std::istreambuf_iterator instead, it seems to me that it doesn't skip any characters.
input_stream >> std::noskipws;

std::vector<char> input;
input.insert(
      input.begin(),
      std::istream_iterator<char>(input_stream),
      std::istream_iterator<char>());
  IValue ivalue = pickle_load(input);