b::swap(x)
(but not b.swap(x)
!) would have worked if swap()
was a static class method. But swap()
is an instance method, and as such, can only work on instance of an object of class b
(which is typedef
of map<int,int>
).
b().swap(x)
does not emit an error because it works on instance of object of class b
. However, this call is not likely to be useful, because this instance b()
is immediately destroyed after instantiating.