cad/kicad: fix build with libc++ 19
As noted in the libc++ 19 release notes [1], std::char_traits<> is now
only provided for char, char8_t, char16_t, char32_t and wchar_t, and any
instantiation for other types will fail.
This causes cad/kicad to fail to compile with clang 19 and libc++ 19,
resulting in errors similar to:
/wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:261:25: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>' 261 | auto const n = std::char_traits<NANODBC_SQLCHAR>::length(array); | ^ /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here 45 | struct char_traits; | ^ /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:3576:52: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>' 3576 | dsn.name = string(&name[0], &name[std::char_traits<NANODBC_SQLCHAR>::length(name)]); | ^ /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here 45 | struct char_traits; | ^ /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:3578:49: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>' 3578 | string(&driver[0], &driver[std::char_traits<NANODBC_SQLCHAR>::length(driver)]); | ^ /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here 45 | struct char_traits; | ^ /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:3629:54: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>' 3629 | drv.name = string(&descr[0], &descr[std::char_traits<NANODBC_SQLCHAR>::length(descr)]); | ^ /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here 45 | struct char_traits; | ^
and:
/usr/include/c++/v1/string:820:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>' 820 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, | ^ /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/compoundfilereader/compoundfilereader.h:226:21: note: in instantiation of template class 'std::basic_string<unsigned short>' requested here 226 | utf16string dir; | ^ /usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here 23 | struct _LIBCPP_TEMPLATE_VIS char_traits; | ^
The first batch of errors can be fixed by providing a simple length()
function for the NANODBC_SQLCHAR const* type. The second batch can be
fixed by using std::basic_string<char16_t> for utf16string, and
adjusting the call to std::basic_string<char16_t>::append.
[1] https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals
PR: 281886
MFH: 2024Q3
(cherry picked from commit 0cb9394fcd48f9247a6b9faa072701b25df6471a)