Do not use no longer supported std::char_traits

/usr/bin/../include/c++/v1/string_view:300:42: error: implicit instantiation of undefined template 'std::char_traits<signed char>'
  300 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
/home/elsid/dev/openmw/components/to_utf8/to_utf8.cpp:55:41: note: in instantiation of template class 'std::basic_string_view<signed char>' requested here
   55 |     std::basic_string_view<signed char> getTranslationArray(FromType sourceEncoding)
      |                                         ^
/usr/bin/../include/c++/v1/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^

std::char_traits support for non char types was removed from libc++19:
https://reviews.llvm.org/D157058.
This commit is contained in:
elsid 2025-02-21 19:14:18 +01:00 committed by Alexei Kotov
parent 569ed4559f
commit e5ad1cd214
2 changed files with 3 additions and 2 deletions

View file

@ -52,7 +52,7 @@ namespace
return std::find_if(input.begin(), input.end(), [](unsigned char v) { return v == 0 || v >= 128; });
}
std::basic_string_view<signed char> getTranslationArray(FromType sourceEncoding)
std::span<const signed char> getTranslationArray(FromType sourceEncoding)
{
switch (sourceEncoding)
{

View file

@ -2,6 +2,7 @@
#define COMPONENTS_TOUTF8_H
#include <cstring>
#include <span>
#include <string>
#include <string_view>
#include <utility>
@ -50,7 +51,7 @@ namespace ToUTF8
inline void copyFromArrayLegacyEnc(
std::string_view::iterator& chp, std::string_view::iterator end, char*& out) const;
const std::basic_string_view<signed char> mTranslationArray;
const std::span<const signed char> mTranslationArray;
};
class Utf8Encoder