@@ -123,7 +123,7 @@ struct OpenHashSet(T, Allocator = Mallocator,
123123 * Returns:
124124 * $(B true) if the hash set contains the given item, false otherwise.
125125 */
126- bool contains (T item) const nothrow @safe
126+ bool contains (T item) const
127127 {
128128 if (empty)
129129 return false ;
@@ -135,7 +135,7 @@ struct OpenHashSet(T, Allocator = Mallocator,
135135 }
136136
137137 // / ditto
138- bool opBinaryRight (string op)(T item) inout nothrow if (op == " in" )
138+ bool opBinaryRight (string op)(T item) inout if (op == " in" )
139139 {
140140 return contains (item);
141141 }
@@ -282,7 +282,7 @@ private:
282282 * Returns:
283283 * size_t.max if the item was not found
284284 */
285- static size_t toIndex (const Node[] n, T item, size_t hash) nothrow @safe
285+ static size_t toIndex (const Node[] n, T item, size_t hash)
286286 {
287287 immutable size_t bucketMask = (n.length - 1 );
288288 immutable size_t index = hash & bucketMask;
@@ -354,3 +354,34 @@ unittest
354354 assert (ohs.remove(0 ));
355355 assert (ohs.remove(1 ));
356356}
357+
358+ unittest
359+ {
360+ static class Foo
361+ {
362+ string name;
363+
364+ override bool opEquals (Object other) const @safe pure nothrow @nogc
365+ {
366+ Foo f = cast (Foo )other;
367+ return f ! is null && f.name == this .name;
368+ }
369+ }
370+
371+ hash_t stringToHash (string str) @safe pure nothrow @nogc
372+ {
373+ hash_t hash = 5381 ;
374+ return hash;
375+ }
376+
377+ hash_t FooToHash (Foo e) pure @safe nothrow @nogc
378+ {
379+ return stringToHash (e.name);
380+ }
381+
382+ OpenHashSet! (Foo , Mallocator, FooToHash) hs;
383+ auto f = new Foo ;
384+ hs.insert(f);
385+ assert (f in hs);
386+ auto r = hs.range();
387+ }
0 commit comments