On Monday, 16 August 2021 at 06:36:02 UTC, james.p.leblanc wrote:
>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;
}
Oh, you're writing T[]
in the code anyways.
I was saying to just remove the :T[]
from the function parameter and write T[]
in the function body itself, which you're already doing.
If the code works, what's the problem?