3 ms·
It's unfortunate that literal strings in C++ cannot be programmatically distinguished from char* buffers. It would be useful if there were a separate type for
by jzwinck 12y ago
It's unfortunate that literal strings in C++ cannot be programmatically distinguished from char* buffers. It would be useful if there were a separate type for literal strings which could implicitly decay to char* when needed. And functions should be able to return that type, because you may have "literal_string toString(MyEnum)" which always returns a literal string (or perhaps null).
Also, yes, Boost has some lock-free stuff now. It didn't back when the author was writing the code described.
- mortoray 12y agoYes, a string-literal type would be very helpful. In my Leaf language I have literal types. I think they offer some good optimiation abilities.
- humanrebar 12y agoThere are user-defined string literals (1) in C++11. They can do pretty much whatever you want. Also, using templates it is trivial to distinguish between arrays of characters and character pointers. Finally, there is a proposal for a string_view (2), which could be used to represent string literals, no copies needed. (1) http://en.cppreference.com/w/cpp/language/user_literal http://en.cppreference.com/w/cpp/language/user_literal (2) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3609.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n360...