|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r80635 - trunk/libs/unordered/test/unordered
From: dnljms_at_[hidden]
Date: 2012-09-22 14:32:23
Author: danieljames
Date: 2012-09-22 14:32:22 EDT (Sat, 22 Sep 2012)
New Revision: 80635
URL: http://svn.boost.org/trac/boost/changeset/80635
Log:
Unordered: A bit more feedback from unnecessary_copy_tests
Text files modified:
trunk/libs/unordered/test/unordered/unnecessary_copy_tests.cpp | 47 +++++++++++++++++++++++++++++++++++----
1 files changed, 42 insertions(+), 5 deletions(-)
Modified: trunk/libs/unordered/test/unordered/unnecessary_copy_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/unnecessary_copy_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/unnecessary_copy_tests.cpp 2012-09-22 14:32:22 EDT (Sat, 22 Sep 2012)
@@ -20,8 +20,17 @@
public:
static int copies;
static int moves;
- count_copies() : tag_(0) { ++copies; }
- explicit count_copies(int tag) : tag_(tag) { ++copies; }
+ static int id_count;
+
+ count_copies() : tag_(0), id_(++id_count) {
+ ++copies;
+ trace_op("Default construct");
+ }
+
+ explicit count_copies(int tag) : tag_(tag), id_(++id_count) {
+ ++copies;
+ trace_op("Tag construct");
+ }
// This bizarre constructor is an attempt to confuse emplace.
//
@@ -33,17 +42,30 @@
// The second emplace should use the single argument contructor for
// the key, and this constructor for the value.
count_copies(count_copies const&, count_copies const& x)
- : tag_(x.tag_) { ++copies; }
+ : tag_(x.tag_), id_(++id_count)
+ {
+ ++copies;
+ trace_op("Pair construct");
+ }
- count_copies(count_copies const& x) : tag_(x.tag_) { ++copies; }
- count_copies(BOOST_RV_REF(count_copies) x) : tag_(x.tag_) {
+ count_copies(count_copies const& x) : tag_(x.tag_), id_(++id_count)
+ {
+ ++copies;
+ trace_op("Copy construct");
+ }
+
+ count_copies(BOOST_RV_REF(count_copies) x) :
+ tag_(x.tag_), id_(++id_count)
+ {
x.tag_ = -1; ++moves;
+ trace_op("Move construct");
}
count_copies& operator=(BOOST_COPY_ASSIGN_REF(count_copies) p) // Copy assignment
{
tag_ = p.tag_;
++copies;
+ trace_op("Copy assign");
return *this;
}
@@ -51,10 +73,21 @@
{
tag_ = p.tag_;
++moves;
+ trace_op("Move assign");
return *this;
}
+ ~count_copies() {
+ trace_op("Destruct");
+ }
+
+ void trace_op(char const* str) {
+ BOOST_LIGHTWEIGHT_TEST_OSTREAM << str << ": " << tag_
+ << " (#" << id_ << ")" <<std::endl;
+ }
+
int tag_;
+ int id_;
};
bool operator==(count_copies const& x, count_copies const& y) {
@@ -69,6 +102,9 @@
void reset() {
count_copies::copies = 0;
count_copies::moves = 0;
+
+ BOOST_LIGHTWEIGHT_TEST_OSTREAM
+ << "\nReset\n" << std::endl;
}
}
@@ -122,6 +158,7 @@
{
int count_copies::copies;
int count_copies::moves;
+ int count_copies::id_count;
template <class T>
void unnecessary_copy_insert_test(T*)
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