mirror of
https://github.com/boostorg/unordered.git
synced 2025-05-12 05:51:44 +00:00
Unordered: Simplify the object count stuff.
[SVN r79355]
This commit is contained in:
parent
ada08d9459
commit
f5292fd9f7
@ -52,30 +52,22 @@ namespace test {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct counted_object
|
|
||||||
{
|
|
||||||
static object_count count_;
|
|
||||||
|
|
||||||
counted_object() { count_.construct(); }
|
|
||||||
counted_object(counted_object const&) { count_.construct(); }
|
|
||||||
~counted_object() { count_.destruct(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T> object_count counted_object<T>::count_;
|
|
||||||
|
|
||||||
struct globally_counted_object
|
|
||||||
: counted_object<globally_counted_object> {};
|
|
||||||
|
|
||||||
// This won't be a problem as I'm only using a single compile unit
|
// This won't be a problem as I'm only using a single compile unit
|
||||||
// in each test (this is actually require by the minimal test
|
// in each test (this is actually require by the minimal test
|
||||||
// framework).
|
// framework).
|
||||||
//
|
//
|
||||||
// boostinspect:nounnamed
|
// boostinspect:nounnamed
|
||||||
namespace {
|
namespace {
|
||||||
object_count& global_object_count = globally_counted_object::count_;
|
object_count global_object_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct counted_object
|
||||||
|
{
|
||||||
|
counted_object() { global_object_count.construct(); }
|
||||||
|
counted_object(counted_object const&) { global_object_count.construct(); }
|
||||||
|
~counted_object() { global_object_count.destruct(); }
|
||||||
|
};
|
||||||
|
|
||||||
struct check_instances {
|
struct check_instances {
|
||||||
int instances;
|
int instances;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace test
|
|||||||
object generate(object const*);
|
object generate(object const*);
|
||||||
implicitly_convertible generate(implicitly_convertible const*);
|
implicitly_convertible generate(implicitly_convertible const*);
|
||||||
|
|
||||||
class object : private globally_counted_object
|
class object : private counted_object
|
||||||
{
|
{
|
||||||
friend class hash;
|
friend class hash;
|
||||||
friend class equal_to;
|
friend class equal_to;
|
||||||
@ -64,7 +64,7 @@ namespace test
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class implicitly_convertible : private globally_counted_object
|
class implicitly_convertible : private counted_object
|
||||||
{
|
{
|
||||||
int tag1_, tag2_;
|
int tag1_, tag2_;
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user