Boost logo

Boost :

From: Karl Nelson (kenelson_at_[hidden])
Date: 2002-02-19 12:23:18


[snip]
> > I think most programmers would expect it to give them the nth
> > character
> > of the formatted string. But I'm just guessing about this.
>
> Interesting. I never looked at it this way. I would suspect that there
> would be very few cases where someone would get confused about the meaning
> in this way. However, if I'm wrong, it would be a good argument against
> operator[].

I would have expected that [] on a format gives access to a
formatting specifications for argument #.

Ie.

    format_expr fmt("%d %s");

    fmt[0] gives "%d"

(Okay it is a bit confusing as printf starts from one.)

I personally view operator [] as "indexing". So
foo[i][j] means "j-th of i-th of foo".

I think the use of .with() or operator() has more merit.
But this is purely personal preference.

--Karl


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