[libcxx-commits] [PATCH] D69940: [libc++] Fixed copy/copy_n/copy_backward for compilers that do not support is_constant_evaluated.
Michael Park via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Nov 7 04:01:16 PST 2019
mpark created this revision.
mpark added a reviewer: ldionne.
Herald added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, dexonsmith, christof.
Herald added a project: libc++.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69940
Files:
libcxx/include/__config
libcxx/include/algorithm
libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
Index: libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
===================================================================
--- libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
+++ libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
@@ -82,7 +82,7 @@
{
test();
-#if TEST_STD_VER > 17
+#if TEST_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
static_assert(test());
#endif
Index: libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
===================================================================
--- libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
+++ libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
@@ -58,7 +58,7 @@
{
test();
-#if TEST_STD_VER > 17
+#if TEST_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
static_assert(test());
#endif
Index: libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
===================================================================
--- libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
+++ libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
@@ -79,7 +79,7 @@
{
test();
-#if TEST_STD_VER > 17
+#if TEST_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
static_assert(test());
#endif
Index: libcxx/include/algorithm
===================================================================
--- libcxx/include/algorithm
+++ libcxx/include/algorithm
@@ -1727,7 +1727,7 @@
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
_OutputIterator
copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
@@ -1780,7 +1780,7 @@
}
template <class _BidirectionalIterator1, class _BidirectionalIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
_BidirectionalIterator2
copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
_BidirectionalIterator2 __result)
@@ -1818,7 +1818,7 @@
// copy_n
template<class _InputIterator, class _Size, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
typename enable_if
<
__is_input_iterator<_InputIterator>::value &&
@@ -1844,7 +1844,7 @@
}
template<class _InputIterator, class _Size, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
typename enable_if
<
__is_random_access_iterator<_InputIterator>::value,
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -1002,6 +1002,14 @@
# define _LIBCPP_CONSTEXPR_AFTER_CXX17
#endif
+#if _LIBCPP_STD_VER > 17 && \
+ !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) && \
+ !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
+# define _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED constexpr
+#else
+# define _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED
+#endif
+
// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other
// NODISCARD macros to the correct attribute.
#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69940.228209.patch
Type: text/x-patch
Size: 3780 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20191107/54b73134/attachment-0001.bin>
More information about the libcxx-commits
mailing list