-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathidnumber.d
More file actions
35 lines (28 loc) · 707 Bytes
/
idnumber.d
File metadata and controls
35 lines (28 loc) · 707 Bytes
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
// idnumber.d
//
// Copyright Peter Williams 2013 <[email protected]>.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module idnumber;
mixin template IdNumber(T) {
const T id;
override hash_t toHash()
{
return id;
}
override bool opEquals(Object o)
{
return id == (cast(typeof(this)) o).id;
}
override int opCmp(Object o)
{
return id - (cast(typeof(this)) o).id;
}
}
mixin template UniqueId(T) {
mixin IdNumber!(T);
protected static T next_id;
const string set_unique_id = "id = next_id++;";
}