Skip to content

Commit

Permalink
First failing try
Browse files Browse the repository at this point in the history
  • Loading branch information
nordlow committed Oct 12, 2014
1 parent a5cd0d8 commit 5c57cb1
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions std/container/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ Comparison for equality.
/**
Defines the container's primary range, which is a random-access range.
*/
static struct Range
static struct Range(A)
{
private Array _outer;
private A _outer;
private size_t _a, _b;

inout private this(inout ref Array data, size_t a, size_t b)
private this(ref A data, size_t a, size_t b)
{
_outer = data;
_a = a;
Expand Down Expand Up @@ -288,18 +288,18 @@ Defines the container's primary range, which is a random-access range.
return move(_outer._data._payload[_a + i]);
}

ref inout(T) opIndex(size_t i) inout
auto ref opIndex(size_t i)
{
version (assert) if (_a + i >= _b) throw new RangeError();
return _outer[_a + i];
}

inout(typeof(this)) opSlice() inout
Range!A opSlice()
{
return typeof(this)(_outer, _a, _b);
}

inout(typeof(this)) opSlice(size_t i, size_t j) inout
Range!A opSlice(size_t i, size_t j)
{
version (assert) if (i > j || _a + j > _b) throw new RangeError();
return typeof(this)(_outer, _a + i, _a + j);
Expand Down Expand Up @@ -427,9 +427,9 @@ forward order.
Complexity: $(BIGOH 1)
*/
Range opSlice() inout
Range!(inout(Array)) opSlice() inout
{
return inout(Range)(this, 0, length);
return typeof(return)(this, 0, length);
}

/**
Expand All @@ -439,11 +439,11 @@ index $(D a) up to (excluding) index $(D b).
Precondition: $(D a <= b && b <= length)
Complexity: $(BIGOH 1)
*/
Range opSlice(size_t i, size_t j) inout
*/
Range!(inout(Array)) opSlice(size_t i, size_t j) inout
{
version (assert) if (i > j || j > length) throw new RangeError();
return inout(Range)(this, i, j);
return typeof(return)(this, i, j);
}

/**
Expand Down Expand Up @@ -695,7 +695,7 @@ Returns: The number of values inserted.
Complexity: $(BIGOH n + m), where $(D m) is the length of $(D stuff)
*/
size_t insertBefore(Stuff)(Range r, Stuff stuff)
size_t insertBefore(Stuff)(Range!Array r, Stuff stuff)
if (isImplicitlyConvertible!(Stuff, T))
{
enforce(r._outer._data is _data && r._a <= length);
Expand All @@ -711,7 +711,7 @@ Complexity: $(BIGOH n + m), where $(D m) is the length of $(D stuff)
}

/// ditto
size_t insertBefore(Stuff)(Range r, Stuff stuff)
size_t insertBefore(Stuff)(Range!Array r, Stuff stuff)
if (isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, T))
{
enforce(r._outer._data is _data && r._a <= length);
Expand Down Expand Up @@ -749,7 +749,7 @@ Complexity: $(BIGOH n + m), where $(D m) is the length of $(D stuff)
}

/// ditto
size_t insertAfter(Stuff)(Range r, Stuff stuff)
size_t insertAfter(Stuff)(Range!Array r, Stuff stuff)
{
enforce(r._outer._data is _data);
// TODO: optimize
Expand All @@ -762,7 +762,7 @@ Complexity: $(BIGOH n + m), where $(D m) is the length of $(D stuff)
}

/// ditto
size_t replace(Stuff)(Range r, Stuff stuff)
size_t replace(Stuff)(Range!Array r, Stuff stuff)
if (isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, T))
{
enforce(r._outer._data is _data);
Expand All @@ -784,7 +784,7 @@ Complexity: $(BIGOH n + m), where $(D m) is the length of $(D stuff)
}

/// ditto
size_t replace(Stuff)(Range r, Stuff stuff)
size_t replace(Stuff)(Range!Array r, Stuff stuff)
if (isImplicitlyConvertible!(Stuff, T))
{
enforce(r._outer._data is _data);
Expand Down Expand Up @@ -813,7 +813,7 @@ initially were right after $(D r).
Complexity: $(BIGOH n - m), where $(D m) is the number of elements in
$(D r)
*/
Range linearRemove(Range r)
Range!Array linearRemove(Range!Array r)
{
enforce(r._outer._data is _data);
enforce(_data.refCountedStore.isInitialized);
Expand Down

0 comments on commit 5c57cb1

Please sign in to comment.