3 ms·
I used to work for a company that whose C++ string class worked like this, although not quite as intricate. Had a separate mode for statically compiled strings
by blt 11y ago
I used to work for a company that whose C++ string class worked like this, although not quite as intricate. Had a separate mode for statically compiled strings too. It was pretty nice, although I didn't agree with every style choice. Makes some branchy code though.
In Visual Studio debugger you can write scripts to pretty-print string variables in the "watch" window, I would guess other good debuggers can do this too.
- crpatino 11y agoString operations are intrinsically complex by nature. At least they are now in this age that you cannot assume the encoding is always ASCII. The goodness of this approach is that if you just need to pass around the string, a shallow copy of the first 16 byte block is enough. It might or might not contain the whole of the array, but if you need to know, it means you need to go through all the corner cases, no strcat(small_buffer, unsanitized_user_input), thank you very much!