Getting a working example of opIndexAssign using opSlice ... have troubles ...
james.p.leblanc
james.p.leblanc at gmail.com
Mon Aug 16 06:36:02 UTC 2021
On Monday, 16 August 2021 at 06:20:11 UTC, Tejas wrote:
> Maybe just write `T[]` in code rather than making it happen via
> the colon?
>
> I also have similar troubles, removing the default value always
> helped me.
>
> Can you show the code where you're trying to apply this?
Hej Tejas,
Sure, here is the code snippet, it resides within a struct
along with various operator overloads.
To be honest, I am not exactly sure what is happening here. I
am unfamiliar with the "(T : T[])" syntax ... need to read
up a bit on that. (However, not so eary searching for a ":")
BR,
jpl
// --- cast overloading
-------------------------------------------
// T[] opCast(T : T[])(){ // this works
T[] opCast(T[])(){ // yields: "Error: identifier expected for
template value param"
T[] x;
x.length = this.length;
for( int i = 0 ; i< this.length ; i++){
x[i] = this.ptr[i];
}
return x;
}
More information about the Digitalmars-d-learn
mailing list