This commit fixes build on CentOS 7 with GCC 4.8.5
Also for std::swap() header <algorithm> is replaced with <utility> one.
This is a backport of Core PR17364 [1/2]
https://github.com/bitcoin/bitcoin/pull/17634/commits/b66861e2e5e8a49e11e7489cf22c3007bc7082cc