[libcxx-commits] [libcxx] [libc++] Optimize std::swap of locales (PR #209760)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 16 22:37:56 PDT 2026
================
@@ -143,8 +143,14 @@ private:
friend bool has_facet(const locale&) _NOEXCEPT;
template <class _Facet>
friend const _Facet& use_facet(const locale&);
+
+ friend void swap(locale&, locale&);
};
+inline void swap(locale& __lhs, locale& __rhs) {
----------------
frederick-vs-ja wrote:
> The standard doesn't allow for a move constructor.
I think the current approach is already slightly non-conforming as it slightly changes the behavior for `std::swap` in overload resolution. See [this reduced example](https://godbolt.org/z/e3vqGsdfK).
Perhaps we should submit an LWG issue to add missing move functions to `locale`.
https://github.com/llvm/llvm-project/pull/209760
More information about the libcxx-commits
mailing list