fixed some bugs in swap methods

6 jobs for v2beta
Status Job ID Name Coverage
  Test
passed #2235
Linux
clang-c++11

00:02:08

passed #2237
Linux
clang-c++98

00:01:43

passed #2234
Linux
gcc-c++11

00:02:54

passed #2236
Linux
gcc-c++98

00:02:36

passed #2238
Apple
macos-c++11

00:02:18

passed #2239
Apple
macos-c++98

00:01:20