Skip to content

Commit 72067b2

Browse files
authored
Update hash-map.dd
This update is in reference to <#4245>. The spec currently says that for classes to be used as keys in associative arrays, they *must* override toHash and opEquals. This is untrue because the default implementations use the address of the class instance for computing the hash and for comparisons.
1 parent 5fc9238 commit 72067b2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spec/hash-map.dd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ $(H2 $(LNAME2 testing_membership, Testing Membership))
8181

8282
$(H2 $(LNAME2 using_classes_as_key, Using Classes as the KeyType))
8383

84-
$(P Classes can be used as the $(I KeyType). For this to work,
85-
the class definition must override the following member functions
84+
$(P Classes can be used as the $(I KeyType). The behavior is controlled by the following member functions
8685
of class $(D Object):)
8786

8887
$(UL
@@ -109,6 +108,8 @@ $(H2 $(LNAME2 using_classes_as_key, Using Classes as the KeyType))
109108
}
110109
}
111110
---
111+
The default implementations of $(D toHash) and $(D opEquals) for classes use $(D is)
112+
semantics (the address of the class instance is used to compute the hash, and the address of the class instance is used for comparisons).
112113

113114
$(IMPLEMENTATION_DEFINED
114115
`opCmp` is not used to check for equality by the

0 commit comments

Comments
 (0)