Although there is no good reason to specialized swap in std namespace, that was not the major problem. The major problem was how swap was called:
std::swap<Poco::Data::Statement>(s1, s2);
I.e. specifying the template argument.
This will match any std-defined swap with the following signature:
template <class T> void swap(anything-at-all);
This causes the *signatures*, not the implementations of all of the following to be instantiated:
template <> void swap(__bit_reference<Poco::Data::Statement> __x, __bit_reference<Poco::Data::Statement> __y) _NOEXCEPT;
template <> void swap(shared_ptr< Poco::Data::Statement >& __x, shared_ptr< Poco::Data::Statement >& __y) _NOEXCEPT;
template <> void swap(weak_ptr<Poco::Data::Statement>& __x, weak_ptr<Poco::Data::Statement>& __y) _NOEXCEPT;
template <> void swap(unique_lock<Poco::Data::Statement>& __x, unique_lock<Poco::Data::Statement>& __y);
etc.
The first signature instantiation listed above is actually the trouble maker. But the rest are questionable, especially the one involving unique_lock. The template parameter for unique_lock should meet the BasicLockable requirements. It is almost certain that Poco::Data::Statement is not a BasicLockable type.
The danger is that simply instantiating a function signature for swap can lead to a compile time error. Maybe unique_lock<T> requires a typedef that Poco::Data::Statement doesn't have? E.g: unique_lock<BasicLockable> requires BasicLockable::is_lock_free to exist. This isn't the case. But this is exactly what happened with __bit_reference<Poco::Data::Statement>:
/usr/include/c++/v1/__bit_reference:26:26: error: no type named '__storage_type' in 'Poco::Data::Statement'
typedef typename _C::__storage_type __storage_type;
~~~~~~~~~~~~~^~~~~~~~~~~~~~
Some day some std-defined type X will get defined that requires some typedef (value_type, difference_type, iterator_category, whatever), that also defines a template <classT> swap(X<T>&, X<T>&), and it will break all code that calls std::swap<MyType>(...).
The cure is two-fold:
1. Don't specify the template argument when you call swap. Just call swap(x, y).
2. Don't qualify namespace std when you call swap unless you *know* that you need to call a swap in namespace std. If you don't know, issue a using std::swap first, to let ADL work its magic.
The first rule is more important than the second.
Here is the libc++ diff that fixed this problem. All that was done was to to create a fake __bit_reference<T> that did not require T to have any nested typedefs.
Index: include/bitset