[libcxx-commits] [libcxx] [libc++] Add move constructor & assignment to `exception_ptr` (PR #164281)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 21 05:51:53 PDT 2025


================
@@ -88,10 +91,26 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
     return !(__x == __y);
   }
 
+  friend _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _NOEXCEPT {
+    void* __tmp = __x.__ptr_;
+    __x.__ptr_  = __y.__ptr_;
+    __y.__ptr_  = __tmp;
+  }
----------------
philnik777 wrote:

It is recommended to use ADL, but that doesn't mean people do it. For that reason alone IMO it's a good idea to not make it a hidden friend. FWIW I don't think http://eel.is/c++draft/hidden.friends actually has any normative effect except that implementations aren't _required_ to provide it through qualified lookup. How would anybody know the difference between the generic swap and the specialized version?
AFAIK the reason for introducing it were overloaded operators, not `swap`.


https://github.com/llvm/llvm-project/pull/164281


More information about the libcxx-commits mailing list