[libcxx-commits] [libcxx] [libc++] Resolve LWG4439 and LWG4300 (PR #174257)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 2 19:16:56 PST 2026


================
@@ -175,6 +175,26 @@ constexpr bool test_swap_ref() {
   }
   return true;
 }
+
+struct ADLSwap {
+  static inline bool called_adl_swap{false};
+
+  friend void swap(ADLSwap&, ADLSwap&) noexcept { called_adl_swap = true; }
----------------
frederick-vs-ja wrote:

I think we should test avoidance of calling ADL-found `swap` on pointers.
```suggestion
  friend void swap(ADLSwap*&, ADLSwap*&) noexcept { called_adl_swap = true; }
```
Also, it might be better to have another case where the `swap` is `= delete;` to ensure that ADL-found `swap` is not even potentially evaluated.

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


More information about the libcxx-commits mailing list