The swap function template was moved from <algorithm> to <utility> in C++0x. Does the former include the latter in C++0x? Or do they both include a common header the defines swap?
In other words, is the following code guaranteed to compile in C++0x?
#include <algorithm> // will this pull in std::swap?
// ...
using std::swap;
swap(a, b);
The FDIS (n3290), in Annex C, “Compatibility”, C.2.7 says:
So no, it’s not guaranteed to compile, this is intentionally a breaking change. Whether individual implementations will actually break C++03 code is another matter. As you point out it’s easy enough for them not to, by defining
swapvia either header. But there’s a choice between making it easier to port C++03 code to C++0x, vs. helping people write strictly conforming C++0x.