For reference, the above solution worked for macOS and ubuntu but failed on windows.
In order for it to work i had to read the stream in binary mode with:
std::ifstream input_stream("ivalue.pt", std::ios::binary);
Thanks again!