Really in need of help with std.container.array.d
"Nordlöw" via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Oct 15 14:15:13 PDT 2014
On Tuesday, 14 October 2014 at 16:08:31 UTC, Robert burner
Schadek wrote:
> On Tuesday, 14 October 2014 at 12:51:29 UTC, Nordlöw wrote:
>
>>
>> Could you please give me a code example? I'm not skilled
>> enough in D to follow this description.
>
> struct Range(T) {
> Array!S array;
> T opIndex(size_t i) {
> return cast(T)array[i];
> }
> }
>
> struct Array(T) {
> Range!(const(T)) opSlice() const {
> return Range!(const(T))(cast(Array!T)array, 0, length);
> }
>
> Range!(T) opSlice() const {
> return Range!(T)(cast(Array!T)array, 0, length);
> }
> }
I tried that at
https://github.com/nordlow/phobos/commit/9daf235d7091f76cd941e29e3c167d559bf56a94
but that triggers a new interesting suite of errors
Error: mutable method
std.container.array.Array!int.Array.__fieldPostBlit is not
callable using a const object
array.d(252,26): Error:
cast(inout(int))this._outer.opIndex(this._a) is not an lvalue
array.d(258,26): Error:
cast(inout(int))this._outer.opIndex(this._b - 1LU) is not an
lvalue
../../std/algorithm.d(2364,9): Error: cannot modify const
expression result
array.d(276,24): Error: template instance
std.algorithm.move!(const(int)) error instantiating
array.d(444,5): instantiated from here:
Range!(const(Array!int))
array.d(856,5): instantiated from here: Array!int
array.d(299,26): Error: cast(int)this._outer.opIndex(this._a + i)
is not an lvalue
Error: mutable method std.container.array.Array!int.Array.~this
is not callable using a const object
array.d(325,30): Error: None of the overloads of 'opSliceAssign'
are callable using a const object, candidates are:
array.d(512,10):
std.container.array.Array!int.Array.opSliceAssign(int value)
array.d(519,10):
std.container.array.Array!int.Array.opSliceAssign(int value,
ulong i, ulong j)
array.d(331,38): Error: None of the overloads of 'opSliceAssign'
are callable using a const object, candidates are:
array.d(512,10):
std.container.array.Array!int.Array.opSliceAssign(int value)
array.d(519,10):
std.container.array.Array!int.Array.opSliceAssign(int value,
ulong i, ulong j)
array.d(304,32): Error: mutable method
std.container.array.Array!int.Array.Range!(Array!int).Range.this
is not callable using a const object
array.d(314,32): Error: mutable method
std.container.array.Array!int.Array.Range!(Array!int).Range.this
is not callable using a const object
array.d(448,5): Error: template instance
std.container.array.Array!int.Array.Range!(Array!int) error
instantiating
array.d(856,5): instantiated from here: Array!int
../../std/typecons.d(3889,17): Error: template instance
object.destroy!(Payload) error instantiating
array.d(169,26): instantiated from here:
RefCounted!(Payload, cast(RefCountedAutoInitialize)0)
array.d(856,5): instantiated from here: Array!int
array.d(885,5): Error: static assert (!true) is false
Comint exited abnormally with code 1 at Wed Oct 15 23:14:37
I'm stuck. Need help.
More information about the Digitalmars-d-learn
mailing list