[libcxx-commits] [PATCH] D138307: [libc++] Remove default definition of std::char_traits

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 18 08:45:13 PST 2022


ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

This patch removes the base template implementation for std::char_traits.
If my reading of http://eel.is/c++draft/char.traits is correct, the
Standard mandates that the library provides specializations for several
types like char and wchar_t, but not any implementation in the base
template. Indeed, such an implementation is bound to be incorrect for
most types anyways, since things like `eof()` and `int_type` will definitely
have to be customized.

Since the base template implementation should not have worked for anyone,
this shouldn't be a breaking change (I expect that anyone defining a
custom character type today will already have to provide their own
specialization of char_traits). However, in theory, this has the
possibility to break some code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138307

Files:
  libcxx/docs/ReleaseNotes.rst
  libcxx/include/__string/char_traits.h
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.compile.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/assign2.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/assign3.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/compare.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/copy.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/eof.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/eq.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/eq_int_type.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/find.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/length.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/lt.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/move.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/not_eof.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/to_char_type.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/to_int_type.pass.cpp
  libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/types.compile.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138307.476497.patch
Type: text/x-patch
Size: 29723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221118/9f162291/attachment-0001.bin>


More information about the libcxx-commits mailing list