[libcxx-commits] [PATCH] D119445: [libc++] Use std::ranges::swap_ranges in swap CPO

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 20 21:21:51 PDT 2022


jloser updated this revision to Diff 431121.
jloser edited the summary of this revision.
jloser added a comment.
Herald added a project: All.

Rebase and add #ifdef.

There isn't a "straightforward" way to fix the header cycle since `__concepts/movable.h` depends on `__concepts/swappable.h`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119445/new/

https://reviews.llvm.org/D119445

Files:
  libcxx/include/__concepts/swappable.h


Index: libcxx/include/__concepts/swappable.h
===================================================================
--- libcxx/include/__concepts/swappable.h
+++ libcxx/include/__concepts/swappable.h
@@ -9,6 +9,7 @@
 #ifndef _LIBCPP___CONCEPTS_SWAPPABLE_H
 #define _LIBCPP___CONCEPTS_SWAPPABLE_H
 
+#include <__algorithm/ranges_swap_ranges.h>
 #include <__concepts/assignable.h>
 #include <__concepts/class_or_enum.h>
 #include <__concepts/common_reference_with.h>
@@ -75,10 +76,13 @@
     constexpr void operator()(_Tp(& __t)[_Size], _Up(& __u)[_Size]) const
       noexcept(noexcept((*this)(*__t, *__u)))
     {
-      // TODO(cjdb): replace with `ranges::swap_ranges`.
+#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
       for (size_t __i = 0; __i < _Size; ++__i) {
         (*this)(__t[__i], __u[__i]);
       }
+#else
+      ranges::swap_ranges(__t, __u);
+#endif
     }
 
     // 2.3   Otherwise, if `E1` and `E2` are lvalues of the same type `T` that models...


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119445.431121.patch
Type: text/x-patch
Size: 965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220521/83ba8e5d/attachment-0001.bin>


More information about the libcxx-commits mailing list