[llvm-branch-commits] [libcxx] 3f43d80 - [libc++] Re-enable workaround for pre-ranges CTAD in std::span

Louis Dionne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Mar 22 04:59:07 PDT 2022


Author: Louis Dionne
Date: 2022-03-22T07:58:56-04:00
New Revision: 3f43d803382d57e3fc010ca19833077d1023e9c9

URL: https://github.com/llvm/llvm-project/commit/3f43d803382d57e3fc010ca19833077d1023e9c9
DIFF: https://github.com/llvm/llvm-project/commit/3f43d803382d57e3fc010ca19833077d1023e9c9.diff

LOG: [libc++] Re-enable workaround for pre-ranges CTAD in std::span

See https://reviews.llvm.org/D121626 for details -- this re-enables the
CTAD we removed, since it does break some stuff as well (even though it's
not nearly as bad as the removed constructors fixed by D121626).

(cherry picked from commit 6a7f0551178e966a686dd48dfa2ea045a35addef)

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

Added: 
    

Modified: 
    libcxx/include/span
    libcxx/test/std/containers/views/span.cons/deduct.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/span b/libcxx/include/span
index b8dbc7e01fd61..f33569031730a 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -622,7 +622,13 @@ template<class _Tp, size_t _Sz>
 template<class _Tp, size_t _Sz>
     span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;
 
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+template<class _Container>
+    span(_Container&) -> span<typename _Container::value_type>;
+
+template<class _Container>
+    span(const _Container&) -> span<const typename _Container::value_type>;
+#else
 template<ranges::contiguous_range _Range>
     span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>;
 #endif

diff  --git a/libcxx/test/std/containers/views/span.cons/deduct.pass.cpp b/libcxx/test/std/containers/views/span.cons/deduct.pass.cpp
index 81632fed711d3..e632feca2e1f1 100644
--- a/libcxx/test/std/containers/views/span.cons/deduct.pass.cpp
+++ b/libcxx/test/std/containers/views/span.cons/deduct.pass.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: libcpp-no-concepts
 
 // <span>
 
@@ -86,7 +85,6 @@ void test_std_array() {
     }
 }
 
-#ifndef _LIBCPP_HAS_NO_INCOMPLETE_RANGES
 void test_range_std_container() {
     {
     std::string str{"ABCDE"};
@@ -104,17 +102,13 @@ void test_range_std_container() {
     assert(s.data() == str.data());
     }
 }
-#endif // _LIBCPP_HAS_NO_INCOMPLETE_RANGES
 
 int main(int, char**)
 {
   test_iterator_sentinel();
   test_c_array();
   test_std_array();
-
-#ifndef _LIBCPP_HAS_NO_INCOMPLETE_RANGES
   test_range_std_container();
-#endif // _LIBCPP_HAS_NO_INCOMPLETE_RANGES
 
   return 0;
 }


        


More information about the llvm-branch-commits mailing list