@@ -879,15 +879,16 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
879879 * Returns:
880880 * true if node was added
881881 */
882- private bool _add (Elem n)
882+ private bool _add (return Elem n)
883883 {
884884 Node result;
885885 static if (! allowDuplicates)
886886 bool added = true ;
887887
888888 if (! _end.left)
889889 {
890- _end.left = _begin = result = allocate(n);
890+ result = allocate(n);
891+ (() @trusted { _end.left = _begin = result; }) ();
891892 }
892893 else
893894 {
@@ -903,7 +904,8 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
903904 //
904905 // add to right of new parent
905906 //
906- newParent.left = result = allocate(n);
907+ result = allocate(n);
908+ (() @trusted { newParent.left = result; }) ();
907909 break ;
908910 }
909911 }
@@ -924,7 +926,8 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
924926 //
925927 // add to right of new parent
926928 //
927- newParent.right = result = allocate(n);
929+ result = allocate(n);
930+ (() @trusted { newParent.right = result; }) ();
928931 break ;
929932 }
930933 }
@@ -933,7 +936,6 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
933936 if (_begin.left)
934937 _begin = _begin.left;
935938 }
936-
937939 static if (allowDuplicates)
938940 {
939941 result.setColor(_end);
@@ -944,8 +946,6 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
944946 }
945947 else
946948 {
947- import std.typecons : Tuple ;
948-
949949 if (added)
950950 {
951951 ++ _length;
@@ -1144,12 +1144,14 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
11441144 {
11451145 int x;
11461146
1147+ @safe :
1148+
11471149 this (int init_x)
11481150 {
11491151 x = init_x;
11501152 }
11511153
1152- size_t toHash () const @safe nothrow
1154+ size_t toHash () const nothrow
11531155 {
11541156 return typeid (x).getHash(&x) ^ 0xF0F0_F0F0;
11551157 }
@@ -1272,7 +1274,9 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
12721274 *
12731275 * Complexity: $(BIGOH m * log(n))
12741276 */
1275- size_t stableInsert (Stuff)(Stuff stuff) if (isInputRange! Stuff && isImplicitlyConvertible! (ElementType! Stuff, Elem))
1277+ size_t stableInsert (Stuff)(scope Stuff stuff)
1278+ if (isInputRange! Stuff &&
1279+ isImplicitlyConvertible! (ElementType! Stuff, Elem))
12761280 {
12771281 size_t result = 0 ;
12781282 static if (allowDuplicates)
@@ -1529,7 +1533,7 @@ assert(equal(rbt[], [5]));
15291533 }
15301534
15311535 /+ + Ditto +/
1532- size_t removeKey (U)(U[] elems)
1536+ size_t removeKey (U)(scope U[] elems)
15331537 if (isImplicitlyConvertible! (U, Elem))
15341538 {
15351539 immutable lenBefore = length;
@@ -1777,7 +1781,7 @@ assert(equal(rbt[], [5]));
17771781 * Check the tree for validity. This is called after every add or remove.
17781782 * This should only be enabled to debug the implementation of the RB Tree.
17791783 */
1780- void check ()
1784+ void check () @trusted
17811785 {
17821786 //
17831787 // check implementation of the tree
0 commit comments