blob: 2219553693790b91d932d790758dab779790ec3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
//************************************************************-*- C++ -*-
// class Unique:
// Mixin class for classes that should never be copied.
//
// Purpose:
// This mixin disables both the copy constructor and the
// assignment operator. It also provides a default equality operator.
//
// History:
// 09/24/96 - vadve - Created (adapted from dHPF).
//
//***************************************************************************
#ifndef UNIQUE_H
#define UNIQUE_H
#include <assert.h>
class Unique
{
protected:
/*ctor*/ Unique () {}
/*dtor*/ virtual ~Unique () {}
public:
virtual bool operator== (const Unique& u1) const;
virtual bool operator!= (const Unique& u1) const;
private:
//
// Disable the copy constructor and the assignment operator
// by making them both private:
//
/*ctor*/ Unique (Unique&) { assert(0); }
virtual Unique& operator= (const Unique& u1) { assert(0);
return *this; }
};
// Unique object equality.
inline bool
Unique::operator==(const Unique& u2) const
{
return (bool) (this == &u2);
}
// Unique object inequality.
inline bool
Unique::operator!=(const Unique& u2) const
{
return (bool) !(this == &u2);
}
#endif
|