What is needed (some method overrides?) in order to read/write binary data to/from std::basic_stringstream? I am trying the following code, but it does not work as I supposed:
std::basic_stringstream<uint64_t> s;
uint64_t a = 9;
s << a;
uint64_t b;
s >> b;
std::cout << b << std::endl;
but I get "0" printed (built with GCC).
std::char_traits<uint64_t>. You won't be able to instantiatestd::basic_stringstream<uint64_t>until you provide one. Now, what is it you are trying to achieve? Your code doesn't make much sense to me. It prints9if you just use plain vanillastd::stringstream, but there's no "binary data" in there, and it's not clear what you mean by that.basic_stringstreamis for those that know what they are doing. What do you actually want to achieve? I am almost sure thatbasic_stringstreamisnt the right tool for it