[libcxx-commits] [libcxx] 68e7e76 - [libc++] Fix constraints for string_view's iterator/sentinel constructor

Joe Loser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 25 08:40:38 PST 2021


Author: Joe Loser
Date: 2021-11-25T11:39:59-05:00
New Revision: 68e7e76a9be022427e572101cde4e00203c9af46

URL: https://github.com/llvm/llvm-project/commit/68e7e76a9be022427e572101cde4e00203c9af46
DIFF: https://github.com/llvm/llvm-project/commit/68e7e76a9be022427e572101cde4e00203c9af46.diff

LOG: [libc++] Fix constraints for string_view's iterator/sentinel constructor

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

Differential Revision: https://reviews.llvm.org/D114561

Added: 
    

Modified: 
    libcxx/include/string_view

Removed: 
    


################################################################################
diff  --git a/libcxx/include/string_view b/libcxx/include/string_view
index 0ad7dcce98482..373b3943b9e02 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -191,8 +191,6 @@ namespace std {
 
 */
 
-#include <__concepts/convertible_to.h>
-#include <__concepts/same_as.h>
 #include <__config>
 #include <__debug>
 #include <__ranges/enable_borrowed_range.h>
@@ -282,7 +280,7 @@ public:
 
 #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)
     {


        


More information about the libcxx-commits mailing list