Boost logo

Boost-Commit :

From: nielsdekker_at_[hidden]
Date: 2008-07-20 08:13:33


Author: niels_dekker
Date: 2008-07-20 08:13:33 EDT (Sun, 20 Jul 2008)
New Revision: 47628
URL: http://svn.boost.org/trac/boost/changeset/47628

Log:
Added swap_test_class swap functions to test/swap_arrays.cpp. My fault, they should have been there already!
Text files modified:
   trunk/libs/utility/swap/test/swap_arrays.cpp | 19 +++++++++++++++++++
   1 files changed, 19 insertions(+), 0 deletions(-)

Modified: trunk/libs/utility/swap/test/swap_arrays.cpp
==============================================================================
--- trunk/libs/utility/swap/test/swap_arrays.cpp (original)
+++ trunk/libs/utility/swap/test/swap_arrays.cpp 2008-07-20 08:13:33 EDT (Sun, 20 Jul 2008)
@@ -11,6 +11,25 @@
 //Put test class in the global namespace
 #include "./swap_test_class.hpp"
 
+//Provide swap function in both the namespace of swap_test_class
+//(which is the global namespace), and the std namespace.
+//It's common to provide a swap function for a class in both
+//namespaces. Scott Meyers recommends doing so: Effectice C++,
+//Third Edition, item 25, "Consider support for a non-throwing swap".
+void swap(swap_test_class& left, swap_test_class& right)
+{
+ left.swap(right);
+}
+
+namespace std
+{
+ template <>
+ void swap(swap_test_class& left, swap_test_class& right)
+ {
+ left.swap(right);
+ }
+}
+
 
 int test_main(int, char*[])
 {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk