[PATCH] D28473: Implement http://wg21.link/P0426 Constexpr for std::char_traits

Marshall Clow via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 9 11:20:40 PST 2017


mclow.lists created this revision.
mclow.lists added reviewers: EricWF, rsmith.
mclow.lists added a subscriber: cfe-commits.

Make `assign`/`length`/`find`/`compare` for `std::char_traits` constexpr.

This makes using `string_view`s at compile time easier.

Use the compiler intrinsics when available.
Note that `__builtin_memchr` is not really appropriate, since it returns a `void *`.
Sadly, this turns a bunch of code into "a twisty little maze of ifdefs, all different", but oh well.


https://reviews.llvm.org/D28473

Files:
  include/__string
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp
  test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28473.83658.patch
Type: text/x-patch
Size: 33373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170109/c4d7a64f/attachment-0001.bin>


More information about the cfe-commits mailing list