Allow ADL for swapping Optional values (#4569)

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 <Poco/Optional.h>
    #include <array>

    using Problematic = Poco::Optional<std::array<int, 42> >;

With an unqualified call to swap, preceded by using std::swap, we allow
argument-dependent lookup to find suitable implementations of swap.
This commit is contained in:
Jouke Witteveen 2024-06-17 16:52:49 +02:00 committed by GitHub
parent c6249d9b3f
commit e00b4de672
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -143,8 +143,9 @@ public:
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