Boost logo

Boost-Commit :

From: nielsdekker_at_[hidden]
Date: 2008-08-20 04:25:23


Author: niels_dekker
Date: 2008-08-20 04:25:23 EDT (Wed, 20 Aug 2008)
New Revision: 48245
URL: http://svn.boost.org/trac/boost/changeset/48245

Log:
Added a data member to swap_test_class and made it EqualityComparable, as I mentioned at "Re: [boost] [swap] Renaming boost_swap_impl::swap_impl and/or its namespace?", http://lists.boost.org/Archives/boost/2008/08/141027.php
Text files modified:
   trunk/libs/utility/swap/test/swap_test_class.hpp | 36 +++++++++++++++++++++++++++++++++---
   1 files changed, 33 insertions(+), 3 deletions(-)

Modified: trunk/libs/utility/swap/test/swap_test_class.hpp
==============================================================================
--- trunk/libs/utility/swap/test/swap_test_class.hpp (original)
+++ trunk/libs/utility/swap/test/swap_test_class.hpp 2008-08-20 04:25:23 EDT (Wed, 20 Aug 2008)
@@ -12,8 +12,11 @@
 
 class swap_test_class
 {
+ int m_data;
 public:
- swap_test_class()
+ explicit swap_test_class(int arg = 0)
+ :
+ m_data(arg)
   {
     ++constructCount();
   }
@@ -23,24 +26,40 @@
     ++destructCount();
   }
 
- swap_test_class(const swap_test_class&)
+ swap_test_class(const swap_test_class& arg)
+ :
+ m_data(arg.m_data)
   {
     ++copyCount();
     ++destructCount();
   }
 
- swap_test_class& operator=(const swap_test_class&)
+ swap_test_class& operator=(const swap_test_class& arg)
   {
+ m_data = arg.m_data;
     ++copyCount();
     return *this;
   }
 
   void swap(swap_test_class& other)
   {
+ const int temp = m_data;
+ m_data = other.m_data;
+ other.m_data = temp;
+
     ++swapCount();
   }
 
+ int get_data() const
+ {
+ return m_data;
+ }
 
+ void set_data(int arg)
+ {
+ m_data = arg;
+ }
+
   static unsigned int swap_count(){ return swapCount(); }
   static unsigned int copy_count(){ return copyCount(); }
   static unsigned int construct_count(){ return constructCount(); }
@@ -81,4 +100,15 @@
 
 };
 
+
+inline bool operator==(const swap_test_class & lhs, const swap_test_class & rhs)
+{
+ return lhs.get_data() == rhs.get_data();
+}
+
+inline bool operator!=(const swap_test_class & lhs, const swap_test_class & rhs)
+{
+ return !(lhs == rhs);
+}
+
 #endif


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