Boost logo

Boost :

From: isis-tech_at_[hidden]
Date: 2001-05-27 02:21:19


--- In boost_at_y..., Douglas Gregor <gregod_at_c...> wrote:
> On Saturday 26 May 2001 10:58 pm, you wrote:
> [snip]
> > PS> But what if we disallow the third level []?
> > e[0] is a paradox even with the other iterator
> > styles: e(0) or e.repeat(0). Should it match
> > anything or nothing? Matching anything is
> > the universal string U. The simplest way out
> > thatI could think of is to disallow it.
>
> One would expect e(0) to match nothing because, presumable, e(1) ==
e,
> e(2) = e >> e, etc. That's what I would expect from the single-
argument forms.
>
> This goes back to the exact problem that came up with the
multidimensional
> array library. The following is ambiguous:
>
> e[3][5]
>
> It could equal e[3] | e[4] | e[5] or it could equal e[15].
> Now you know why I support using the () syntax or a repeat function
instead
> of operator[].
>
> I mentioned it back in the multidim library discussions, so I'll
mention it
> here. If we wanted a large degree of flexibility (as was needed for
array
> slicing), we could support syntax like:
>
> e[0 <= stride(2) <= 8]
>
> which is equivalent to:
>
> e[0] | e[2] | e[4] | e[6] | e[8]
>
> Doug
========================================
Is it just me? Whuy am I not getting
the messages from the boost mailing list?
=========================================

Anyway, consider this:

struct X { X1 operator[](uint n) const; };
struct X1 { X2 operator[](uint n) const; };
struct X2 {};

Now:

X x;

x[1]; ... yields an X1 type
x[1][2]; ... yields an X2 type
x[1][2][3]; ... no such operator in X2

Joel de Guzman


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