|
9 | 9 | #ifndef _LIBCPP___STRING_CHAR_TRAITS_H |
10 | 10 | #define _LIBCPP___STRING_CHAR_TRAITS_H |
11 | 11 |
|
12 | | -#include <__algorithm/copy_n.h> |
13 | 12 | #include <__algorithm/fill_n.h> |
14 | 13 | #include <__algorithm/find_end.h> |
15 | 14 | #include <__algorithm/find_first_of.h> |
@@ -144,7 +143,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> { |
144 | 143 | copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { |
145 | 144 | _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2), |
146 | 145 | "char_traits::copy: source and destination ranges overlap"); |
147 | | - std::copy_n(__s2, __n, __s1); |
| 146 | + std::__constexpr_memmove(__s1, __s2, __element_count(__n)); |
148 | 147 | return __s1; |
149 | 148 | } |
150 | 149 |
|
@@ -221,7 +220,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> { |
221 | 220 | copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { |
222 | 221 | _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2), |
223 | 222 | "char_traits::copy: source and destination ranges overlap"); |
224 | | - std::copy_n(__s2, __n, __s1); |
| 223 | + std::__constexpr_memmove(__s1, __s2, __element_count(__n)); |
225 | 224 | return __s1; |
226 | 225 | } |
227 | 226 |
|
@@ -287,7 +286,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> { |
287 | 286 | copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { |
288 | 287 | _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2), |
289 | 288 | "char_traits::copy: source and destination ranges overlap"); |
290 | | - std::copy_n(__s2, __n, __s1); |
| 289 | + std::__constexpr_memmove(__s1, __s2, __element_count(__n)); |
291 | 290 | return __s1; |
292 | 291 | } |
293 | 292 |
|
@@ -366,7 +365,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t> { |
366 | 365 | copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { |
367 | 366 | _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2), |
368 | 367 | "char_traits::copy: source and destination ranges overlap"); |
369 | | - std::copy_n(__s2, __n, __s1); |
| 368 | + std::__constexpr_memmove(__s1, __s2, __element_count(__n)); |
370 | 369 | return __s1; |
371 | 370 | } |
372 | 371 |
|
@@ -454,7 +453,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t> { |
454 | 453 |
|
455 | 454 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type* |
456 | 455 | copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { |
457 | | - std::copy_n(__s2, __n, __s1); |
| 456 | + std::__constexpr_memmove(__s1, __s2, __element_count(__n)); |
458 | 457 | return __s1; |
459 | 458 | } |
460 | 459 |
|
|
0 commit comments