Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2001-05-25 19:06:22


On Friday 25 May 2001 07:19 pm, you wrote:
> From: "Douglas Gregor":
> > The bracket notation unfortunately can't be used for everything, because
> > digit[0, 2] == digit[2]
>
> [] can't have 2 parameters. Is that what you mean?
>
> can't have:
>
> struct X {
> int operator [] (int, int);
> };
>
> So we're left with the () op.
>
> ... Right....
>
> Seigh, I kinda liked [] for iteration to distinguish from
> grouping ex:
>
> (a | b | c)[0, more];
>
> instead of
>
> (a | b | c)(0, more);
>
> Oh well...
> Joel de Guzman

Actually, the use you describe above is possible. If more has a distinct type
(i.e., more_t), then you can overload the comma operator to combine the 0 and
the more into a single object, then accept that object in operator[]. The
Boost multidimensional array library will likely take this approach.

It's the [0, 2] that won't work and would be very, very bad. Since
a[0, 2] == a[2] == lots of user errors.

        Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk