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

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 27 13:23:34 PDT 2025


================
@@ -88,10 +100,18 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
     return !(__x == __y);
   }
 
+  friend _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _NOEXCEPT;
+
   friend _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;
   friend _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
 };
 
+inline _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:

```suggestion
  swap(__x.__ptr_, __y.__ptr_);
```

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


More information about the libcxx-commits mailing list