
Howard Hinnant wrote:
On Jun 23, 2008, at 3:54 PM, David Abrahams wrote:
I haven't formed an opinion yet, but the fact remains that swapping a boost::array would have very different efficiency characteristics from swapping the analogous std::vector, so we ought to think it through carefully.
If it helps, here is a test program using gcc 4.0.1:
On my machine:
$ g++ -O3 test.cpp $ ./a.out swap1 time is 0.172796 seconds swap2 time is 1.3e-05 seconds
I also note that swap1 can throw exceptions and swap2 can't. I also note that move semantics will greatly speed swap1, and make it nothrow, but I still expect swap1 with move semantics to be about twice as slow as swap2.
Your program gives about the results I'd have expected for the case you tested, but it doesn't address what I was concerned about. -- Dave Abrahams BoostPro Computing http://www.boostpro.com