July 18, 2004
This crashes on DMD 0.95 XP SP1. The issue is the use of [] syntax to invoke opIndex.

module test;

template Test()
{
    bit opIndex(bit x)
    {
        return !x;
    }
}

void main()
{
    mixin Test!() xs;
    bit x = xs[false];
}

I'm not sure if it is allowed, but I don't see why not.


July 20, 2004
It shouldn't be allowed, since operator overloading is for structs and classes.

"Bent Rasmussen" <exo@bent-rasmussen.info> wrote in message news:cdcrm9$1u85$1@digitaldaemon.com...
> This crashes on DMD 0.95 XP SP1. The issue is the use of [] syntax to
invoke
> opIndex.
>
> module test;
>
> template Test()
> {
>     bit opIndex(bit x)
>     {
>         return !x;
>     }
> }
>
> void main()
> {
>     mixin Test!() xs;
>     bit x = xs[false];
> }
>
> I'm not sure if it is allowed, but I don't see why not.
>
>