@@ -679,15 +679,15 @@ private struct RBRange(N)
679
679
/**
680
680
* Returns the first element in the range
681
681
*/
682
- @property Elem front()
682
+ ref @property Elem front()
683
683
{
684
684
return _begin.value;
685
685
}
686
686
687
687
/**
688
688
* Returns the last element in the range
689
689
*/
690
- @property Elem back()
690
+ ref @property Elem back()
691
691
{
692
692
return _end.prev.value;
693
693
}
@@ -737,6 +737,10 @@ private struct RBRange(N)
737
737
* elements `a` and `b`, $(D less(a, b) == !less(b, a)). $(D less(a, a)) should
738
738
* always equal `false`.
739
739
*
740
+ * Care should also be taken to not modify elements in the tree (e.g. via `front` /
741
+ * `back`, which return by `ref`) in a way which would affect the order defined by
742
+ * the `less` predicate.
743
+ *
740
744
* If `allowDuplicates` is set to `true`, then inserting the same element more than
741
745
* once continues to add more elements. If it is `false`, duplicate elements are
742
746
* ignored on insertion. If duplicates are allowed, then new elements are
@@ -1036,7 +1040,7 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
1036
1040
*
1037
1041
* Complexity: $(BIGOH 1)
1038
1042
*/
1039
- inout (Elem) front () inout
1043
+ ref inout (Elem) front () inout
1040
1044
{
1041
1045
return _begin.value;
1042
1046
}
@@ -1046,7 +1050,7 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
1046
1050
*
1047
1051
* Complexity: $(BIGOH log(n))
1048
1052
*/
1049
- inout (Elem) back () inout
1053
+ ref inout (Elem) back () inout
1050
1054
{
1051
1055
return _end.prev.value;
1052
1056
}
0 commit comments