opIndexOpAssignOpDispatch
Basile B.
b2.temp at gmx.com
Sat Jun 15 08:33:07 UTC 2024
On Saturday, 15 June 2024 at 04:58:58 UTC, monkyyy wrote:
> ```d
> mystruct foo;
> foo[1337].isnull=true;
> ```
> =>
> `foo.opIndexOpAssignOpDispatch!"isnull"(1337,true)`
>
> it fits the naming scheme!
You can implement an opIndex overload that returns a struct that
itself supports opDispatch.
```d
struct Foo
{
struct opIndexResult
{
Foo* that;
auto opDispatch(string member, T)(T t)
{
}
}
auto opIndex(T)(T t)
{
return opIndexResult(&this);
}
}
void main()
{
Foo foo;
foo[1337].isnull = true;
}
```
dont underestimate what's already possible !
More information about the dip.ideas
mailing list