New operators opStaticIndex and friends
Exil
Exil at gmall.com
Wed May 15 20:04:29 UTC 2019
On Wednesday, 15 May 2019 at 09:05:20 UTC, Simen Kjærås wrote:
> On Wednesday, 15 May 2019 at 01:42:57 UTC, Exil wrote:
>> Does it need to be called opStaticIndex? Could it just be
>> called opIndex and require the specific template arguments. If
>> you define opIndex(int)() now, it will never be called right
>> (unless you specifically invoke it)?
>
> Correct. But opIndex(T...)(Foo!T t) may be, and could then be
> called as either
>
> s[0](Foo!0.init)
>
> or
>
> s[Foo!0.init]
>
> Not sure if this is a big issue, but it's at least indicative
> of possible other issues.
>
> --
> Simen
s[0](Foo!0.init) // -> s.opIndex!(0)()(Foo!0.init)
s[Foo!0.init] // -> s.opIndex(Foo!0.init);
If it compiled would entire depend on what opIndex returns, the
arguments passed to opIndex() are the values in "[]" not the
brackets, which is a separate call.
Unless you meant this?
s[0, Foo!0.init];
Which would then be difficult to know which function to call as
it takes in a compile-time value and a run-time value.
More information about the Digitalmars-d
mailing list