Skip to content

undefined template 'std::char_traits<unsigned char>' #46

@inglorion

Description

@inglorion

Attempting to build dptf (revision 00b9ac1) with recent libc++ fails with errors like the following:

In file included from /tmp/dptf/DPTF/Sources/Libraries/ConfigurationFileContent/ConfigurationFileContent.cpp:21:
/tmp/dptf/DPTF/Linux/Libraries/../../Sources/ThirdParty/nlohmann_json/json.hpp:6221:19: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>'                                                                                                   
 6221 |     typename std::char_traits<char_type>::int_type get_character()
      |                   ^
/tmp/dptf/DPTF/Linux/Libraries/../../Sources/ThirdParty/nlohmann_json/json.hpp:23789:19: note: in instantiation of template class 'nlohmann::detail::iterator_input_adapter<std::__wrap_iter<const unsigned char *>>' requested here
 23789 |         auto ia = detail::input_adapter(std::forward<InputType>(i));
       |                   ^
/tmp/dptf/DPTF/Sources/Libraries/ConfigurationFileContent/ConfigurationFileContent.cpp:137:21: note: in instantiation of function template specialization 'nlohmann::basic_json<>::from_bson<const std::vector<unsigned char> &>' requested here
  137 |                 auto data = json::from_bson(segment);
      |                                   ^
/usr/bin/../include/c++/v1/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^

A specialization of char_traits for char is required to exist, but not for unsigned char. Previously, libc++ had a default implementation of char_traits for arbitrary types, but this has been deprecated for some time and was removed in https://reviews.llvm.org/D157058. As a result, char_traits<unsigned char> now fails to compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions