I just upgraded from Xcode 16.2 to Xcode 16.3, compiling with C++11.
I have been using this definition for years:
typedef std::basic_string<unsigned char> ustring;
But now, apparently, this functionality has been removed? Indeed, I see in the header for char_traits.h
:
struct char_traits; /*The Standard does not define the base template for char_traits because it is impossible to provide etc etc
It had been working up until I upgraded my compiler, as a "temporary" definition had been provided.
The error message now is this:
implicit instantiation of undefined template 'std::char_traits<unsigned char>'
I tried just copying the temp definition from the headers of 16.2, but when I compile I get this error:
/Applications/Xcode-16.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/string:821:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned int>'821 | static_assert(is_same<_CharT, typename traits_type::char_type>::value,
I definitely have no definition of std::char_traits<unsigned int>
, and I have never had it. It compiled before, and now it doesn't with the same, unchanged code, even when I copy the missing part from the previous header.
Not sure what to do. I'm surprised it's so difficult just to declare a std::string
with an unsigned char
(I use them everywhere in code to denote UTF-8 strings).
I know that C++20 has char8_t
, but my app is MONUMENTAL and I just need a quick fix to get my ustring
defined again in C++11.
Anyone have a drop-in replacement for C++11 in Xcode 16.3?
A minimal app is this:
#include <string>typedef std::basic_string<unsigned char> ustring;void main(){ ustring str((const unsigned char *)"hello"); printf("%s\n", (const char *)str.c_str());}