From 459be4704aedf5901e59cdf7779fd9fee3a023ed Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Fri, 22 Aug 2014 14:48:35 -0700 Subject: [PATCH] More complete operator overloading --- actypes.d | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/actypes.d b/actypes.d index 29ab41f..70bf67a 100644 --- a/actypes.d +++ b/actypes.d @@ -90,7 +90,7 @@ public: this.type = type; } - int opCmp(ref const ACSymbol other) const + int opCmp(ref const ACSymbol other) const pure nothrow @safe { // Compare the pointers because the strings have been interned. // Identical strings MUST have the same address @@ -101,6 +101,16 @@ public: return 0; } + bool opEquals(ref const ACSymbol other) const pure nothrow @safe + { + return other.name.ptr == this.name.ptr; + } + + size_t toHash() const pure nothrow @safe + { + return (cast(size_t) name.ptr) * 27_644_437; + } + /** * Gets all parts whose name matches the given string. */