[libcxx-commits] [PATCH] D114561: [libc++] Fix constraints for string_view's iterator/sentinel constructor

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 24 12:38:51 PST 2021


jloser created this revision.
jloser added reviewers: Quuxplusone, Mordante, ldionne.
Herald added a subscriber: kristof.beyls.
jloser requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

The `string_view` constructor taking an iterator/sentinel uses concepts
instead of type traits like the Standard states. Using `same_as` instead
of `is_same_v` should be harmless. Prefer `std::is_same_v` instead which is
cheaper to compile. Replace `convertible_to` with `is_convertible_v` as
well.

This observation came up while working on
https://reviews.llvm.org/D113161


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114561

Files:
  libcxx/include/string_view


Index: libcxx/include/string_view
===================================================================
--- libcxx/include/string_view
+++ libcxx/include/string_view
@@ -282,7 +282,7 @@
 
 #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
     template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
-      requires (same_as<iter_value_t<_It>, _CharT> && !convertible_to<_End, size_type>)
+      requires (is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>)
     constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end)
        : __data(_VSTD::to_address(__begin)), __size(__end - __begin)
     {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114561.389596.patch
Type: text/x-patch
Size: 656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211124/e5f0bb23/attachment.bin>


More information about the libcxx-commits mailing list