[PATCH] D82230: [ADT] Specialize std::swap() for SetVector

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 14:14:15 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGb9c2dd11a513: [ADT] Specialize std::swap() for SetVector (authored by nikic).

Changed prior to commit:
  https://reviews.llvm.org/D82230?vs=272162&id=277568#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82230

Files:
  llvm/include/llvm/ADT/SetVector.h


Index: llvm/include/llvm/ADT/SetVector.h
===================================================================
--- llvm/include/llvm/ADT/SetVector.h
+++ llvm/include/llvm/ADT/SetVector.h
@@ -263,6 +263,11 @@
       remove(*SI);
   }
 
+  void swap(SetVector<T, Vector, Set> &RHS) {
+    set_.swap(RHS.set_);
+    vector_.swap(RHS.vector_);
+  }
+
 private:
   /// A wrapper predicate designed for use with std::remove_if.
   ///
@@ -308,4 +313,22 @@
 
 } // end namespace llvm
 
+namespace std {
+
+/// Implement std::swap in terms of SetVector swap.
+template<typename T, typename V, typename S>
+inline void
+swap(llvm::SetVector<T, V, S> &LHS, llvm::SetVector<T, V, S> &RHS) {
+  LHS.swap(RHS);
+}
+
+/// Implement std::swap in terms of SmallSetVector swap.
+template<typename T, unsigned N>
+inline void
+swap(llvm::SmallSetVector<T, N> &LHS, llvm::SmallSetVector<T, N> &RHS) {
+  LHS.swap(RHS);
+}
+
+} // end namespace std
+
 #endif // LLVM_ADT_SETVECTOR_H


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82230.277568.patch
Type: text/x-patch
Size: 961 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200713/de821b0b/attachment-0001.bin>


More information about the llvm-commits mailing list