On Wed, Jul 9, 2014 at 2:51 PM, Andrey Semashev
On Wednesday 09 July 2014 14:42:55 Beman Dawes wrote:
I'm working on an update of Boost.Filesystem that adds support for the C++11 char16_t, char23_t, u16string, and u32string types.
For compilers that don't yet support these types, a header cxx11_char_types.hpp (see attached) provides emulation that is good enough for filesystem, and is probably useful for other libraries and for user code too. We discussed this header several years ago, and I've been using it since then.
Where should this header live? It can certainly go in libs/filesystem/include/boost/filesystem, but that doesn't really expose it to general Boost users. Is there a better place, but without introducing unwanted dependencies?
Are string typedefs generally useful in C++03?
Yes, at least in applications that are not crippled by a compiler that also lacks Unicode literals. E.g. does
std::char_traitsboost::char16::length() work?
Yes, at least for GCC and MSVC. Have not tested other compilers.
It would be needed if one to construct u16string from a literal.
Compilers that don't support char16_t/char32_t usually don't support Unicode literals. So you end up writing code like this: // Test with cases that require UTF-16 surrogate pairs // U+1F60A SMILING FACE WITH SMILING EYES // U+1F60E SMILING FACE WITH SUNGLASSES // build test strings character by character so they work with C++03 compilers const char32 u32c[] = {0x1F60A, 0x1F60E, 0}; const char16 u16c[] = {0xD83D, 0xDE0A, 0xD83D, 0xDE0E, 0}; const u32string u32s(u32c); const u16string u16s(u16c); const string u8s("\xF0\x9F\x98\x8A\xF0\x9F\x98\x8E"); const string chars("\xF0\x9F\x98\x8A\xF0\x9F\x98\x8E");
If not these typedefs should not be exposed to users, IMHO.
The cat is already out of the bag. Microsoft has been exposing them for several releases.
Otherwise, cstdint.hpp is in Boost.Config, and this header offers similar functionality.
Makes sense. --Beman