4

I am using C++17 on macOS and char16_t is not acceptable as a template parameter as follow:

basic_ifstream<char16_t> file("c:\\file.txt", ios_base::ate);
streamsize size = file.tellg();
file.seekg(0, ios_base::beg);
u16string str(size/2, 0);
file.read(reinterpret_cast<char16_t*>(&str[0]), size);
file.close();

The previous code is working on windows but it doesn't work on macOS.

Also, there are indirect error implicit instantiation of undefined template std::__1::ctype<char16_t> appears in "istream.h", "__locale.h" and when change char16_t to something else that error disappear.

Is there a solution to that problem or it's like the other poor things that in c++?

Lion King
  • 32,851
  • 25
  • 81
  • 143

0 Answers0