[libcxx-commits] [libcxx] 6a7f055 - [libc++] Re-enable workaround for pre-ranges CTAD in std::span
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 21 18:56:51 PDT 2022
Author: Louis Dionne
Date: 2022-03-21T21:56:42-04:00
New Revision: 6a7f0551178e966a686dd48dfa2ea045a35addef
URL: https://github.com/llvm/llvm-project/commit/6a7f0551178e966a686dd48dfa2ea045a35addef
DIFF: https://github.com/llvm/llvm-project/commit/6a7f0551178e966a686dd48dfa2ea045a35addef.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).
Differential Revision: https://reviews.llvm.org/D122184
Added:
Modified:
libcxx/include/span
libcxx/test/std/containers/views/span.cons/deduct.pass.cpp
libcxx/test/support/test_macros.h
Removed:
################################################################################
diff --git a/libcxx/include/span b/libcxx/include/span
index 5a2670d917537..adb7d000488d0 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -610,7 +610,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_INCOMPLETE_RANGES)
+#if 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 adf928dadc5f7..e632feca2e1f1 100644
--- a/libcxx/test/std/containers/views/span.cons/deduct.pass.cpp
+++ b/libcxx/test/std/containers/views/span.cons/deduct.pass.cpp
@@ -85,7 +85,6 @@ void test_std_array() {
}
}
-#ifndef TEST_HAS_NO_INCOMPLETE_RANGES
void test_range_std_container() {
{
std::string str{"ABCDE"};
@@ -103,17 +102,13 @@ void test_range_std_container() {
assert(s.data() == str.data());
}
}
-#endif // TEST_HAS_NO_INCOMPLETE_RANGES
int main(int, char**)
{
test_iterator_sentinel();
test_c_array();
test_std_array();
-
-#ifndef TEST_HAS_NO_INCOMPLETE_RANGES
test_range_std_container();
-#endif // TEST_HAS_NO_INCOMPLETE_RANGES
return 0;
}
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index 08d3865b67ffd..aa6159496018f 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -389,10 +389,6 @@ inline void DoNotOptimize(Tp const& value) {
# define TEST_HAS_NO_FGETPOS_FSETPOS
#endif
-#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
-# define TEST_HAS_NO_INCOMPLETE_RANGES
-#endif
-
#if defined(TEST_COMPILER_CLANG)
# define TEST_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
# define TEST_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
More information about the libcxx-commits
mailing list