Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82116 - sandbox/static_vector/test
From: adam.wulkiewicz_at_[hidden]
Date: 2012-12-20 10:27:55


Author: awulkiew
Date: 2012-12-20 10:27:55 EST (Thu, 20 Dec 2012)
New Revision: 82116
URL: http://svn.boost.org/trac/boost/changeset/82116

Log:
Added BOOST_COPYABLE_AND_MOVABLE to conting_value.
Text files modified:
   sandbox/static_vector/test/static_vector.cpp | 29 +++++------------------------
   1 files changed, 5 insertions(+), 24 deletions(-)

Modified: sandbox/static_vector/test/static_vector.cpp
==============================================================================
--- sandbox/static_vector/test/static_vector.cpp (original)
+++ sandbox/static_vector/test/static_vector.cpp 2012-12-20 10:27:55 EST (Thu, 20 Dec 2012)
@@ -59,37 +59,18 @@
 
 class counting_value
 {
+ BOOST_COPYABLE_AND_MOVABLE(counting_value)
+
 public:
     explicit counting_value(int a = 0) : aa(a) { ++c(); }
     counting_value(counting_value const& v) : aa(v.aa) { ++c(); }
- //counting_value & operator=(counting_value const& v) { aa = v.aa; return *this; }
+ counting_value(BOOST_RV_REF(counting_value) p) : aa(p.aa) { p.aa = 0; ++c(); } // Move constructor
+ counting_value& operator=(BOOST_RV_REF(counting_value) p) { aa = p.aa; p.aa = 0; return *this; } // Move assignment
+ counting_value& operator=(BOOST_COPY_ASSIGN_REF(counting_value) p) { aa = p.aa; return *this; } // Copy assignment
     ~counting_value() { --c(); }
     bool operator==(counting_value const& v) const { return aa == v.aa; }
     static size_t count() { return c(); }
- static void init() { c() = 0; }
-
-
- counting_value& operator=(BOOST_COPY_ASSIGN_REF(counting_value) p) // Copy assignment
- {
- if (this != &p){
- int tmp_aa = p.aa ? p.aa : 0;
- aa = tmp_aa;
- }
- return *this;
- }
 
- //Move semantics...
- counting_value(BOOST_RV_REF(counting_value) p) //Move constructor
- : aa(p.aa) { p.aa = 0; }
-
- counting_value& operator=(BOOST_RV_REF(counting_value) p) //Move assignment
- {
- if (this != &p){
- aa = p.aa;
- p.aa = 0;
- }
- return *this;
- }
 private:
     static size_t & c() { static size_t co = 0; return co; }
     int aa;


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