From 633832e872a05b02e018f598f5d42bffe7941139 Mon Sep 17 00:00:00 2001
From: Niels Dekker
The template function boost::swap allows the values of two variables to be swapped, using argument dependent lookup to select a specialized swap function if available. If no specialized swap function is available, std::swap is used.
@@ -24,10 +24,10 @@The generic std::swap function requires that the elements to be swapped are assignable and copy constructible. It is usually implemented using one copy construction and two assignments - this is often both unnecessarily restrictive and unnecessarily slow. In addition, where the generic swap implementation provides only the basic guarantee, specialized swap functions are often able to provide the no-throw exception guarantee (and it is considered best practice to do so where possible1).
- The alternative to using argument dependent lookup in this situation is to provide a template specialization of std::swap for every type that requires a specialized swap. Although this is legal C++, no Boost libraries use this method, whereas many Boost libraries provide specialized swap functions in their own namespaces. + The alternative to using argument dependent lookup in this situation is to provide a template specialization of std::swap for every type that requires a specialized swap. Although this is legal C++, no Boost libraries use this method, whereas many Boost libraries provide specialized swap functions in their own namespaces.
- boost::swap also supports swapping built-in arrays. Note that std::swap doesn't yet do so, but a request to add an overload of std::swap for built-in arrays has been well-received by the Library Working Group of the C++ Standards Committee2. + boost::swap also supports swapping built-in arrays. Note that std::swap originally did not do so, but a request to add an overload of std::swap for built-in arrays has been accepted by the C++ Standards Committee2.
@@ -45,11 +45,11 @@Or:
Or:
Or:
[1]Scott Meyers, Effective C++ Third Edition, Item 25: "Consider support for a non-throwing swap"
-[2]LWG issue 809 (std::swap should be overloaded for array types)
+[2]LWG Defect Report 809 (std::swap should be overloaded for array types)
Revised: 21 October 2008
+Revised: 15 November 2008
Copyright 2007, 2008 Joseph Gauterin. Use, modification, and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)