How can I use decimal notation without resorting to a reinterpret_cast and ugly #ifdefs?
I tried this:
std::stringstream ss; void *test = (void *)0x12345678; // Output pointer as decimal number ss << std::ios::dec << test; // Works! // Read pointer from decimal number void *x; ss << dec; // Nope ss.setf(std::ios::dec); // No change ss >> dec >> x; // Neither
All the input variants do nothing. The pointer will not be assigned and keeps its "help I'm uninitialized" value of 0xcccccccc. The fail bit of the stream is set - probably because it tried to _still_ parse the number in hex and it was too large.