From d58c58c53b3b283f0dfe49aa4a143d82cff08edf Mon Sep 17 00:00:00 2001 From: Jouke Witteveen Date: Tue, 28 May 2024 16:08:28 +0200 Subject: [PATCH] Allow ADL for swapping Optional values Some types support being swapped but may not have declared their std::swap overloads when Poco/Optional.h is first included. This is the case for instance with #include #include using Problematic = Poco::Optional >; With an unqualified call to swap, preceded by using std::swap, we allow argument-dependent lookup to find suitable implementations of swap. --- Foundation/include/Poco/Optional.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Foundation/include/Poco/Optional.h b/Foundation/include/Poco/Optional.h index 31c38fd5a8..6b24a4356e 100644 --- a/Foundation/include/Poco/Optional.h +++ b/Foundation/include/Poco/Optional.h @@ -143,8 +143,9 @@ class Optional void swap(Optional& other) noexcept { - std::swap(_value, other._value); - std::swap(_isSpecified, other._isSpecified); + using std::swap; + swap(_value, other._value); + swap(_isSpecified, other._isSpecified); } const C& value() const