[libcxx-commits] [PATCH] D125586: Fix broken SFINAE in std::__copy for trivially copyable types.
Daniel Cheng via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 13 14:56:50 PDT 2022
dcheng created this revision.
Herald added a project: All.
dcheng requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
With the broken SFINAE, std::copy will never use memmove, even for
trivially copyable types.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125586
Files:
libcxx/include/__algorithm/copy.h
Index: libcxx/include/__algorithm/copy.h
===================================================================
--- libcxx/include/__algorithm/copy.h
+++ libcxx/include/__algorithm/copy.h
@@ -80,19 +80,18 @@
}
template <class _InIter, class _Sent, class _OutIter,
- __enable_if_t<is_copy_constructible<_InIter>::value
- && is_copy_constructible<_Sent>::value
- && is_copy_constructible<_OutIter>::value> >
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {
+ class __enable_if_t<is_copy_constructible<_InIter>::value && is_copy_constructible<_Sent>::value &&
+ is_copy_constructible<_OutIter>::value> >
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last,
+ _OutIter __result) {
auto __ret = std::__copy_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result));
return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator copy(_InputIterator __first,
+ _InputIterator __last,
+ _OutputIterator __result) {
return std::__copy(__first, __last, __result).second;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125586.429362.patch
Type: text/x-patch
Size: 1866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220513/eb11fbb9/attachment.bin>
More information about the libcxx-commits
mailing list