From: Karl Nelson (kenelson_at_[hidden])
Date: 2002-02-11 13:18:49
> --- In boost_at_y..., Karl Nelson <kenelson_at_e...> wrote:
> > > From: "Karl Nelson" <kenelson_at_e...>
> > > > Second, what is reasonable here? Under Microsoft .Net they
> allow the
> > > > same argument to be used multiple times. Or an argument not to
> > > > used. Should this be valid?
> > > >
> > > > cout << format("%2$d %2$x", i, i);
> > >
> > > Why not?
> > It drives down preformance because you must now scan the format
> > strings list to find out all the places the string is used and
> > do the conversions. Also it breaks 1-1 correspondence with the
> > arguments. But then if it is needed that it should have it.
> > Does it need it?
> > --Karl
> On one hand if it really hurt a performance I would prefer in some
> cases not to support this. OTOH it could be convinient. Could you
> postpone this decision into a policy?
It depends on how it is implemented. If you go with the
naive approach of just adding support for it to all, you take the code
size hit regardless because every templated argument type would
need to support searching the list, but the run time penality
would only be checking a flag, unless it was used.
If you make it a policy then the question becomes how to
make a good dividing line and make the syntax clear where
one is used, ie...
cout << format(policy1, gettext("1: %1$s %1%x"), c,d,e);
cout << format(policy2, gettext("2: %1$s %2%x"), c,d,e);
cout << format(policy2, gettext("3: %1$s %2%x"), c,d);
So policy1 does accept multiple arguments, but policy2 doesn't
but both accept more than specified arguements, but not policy3
which would throw an exception. Wouldn't that get very very
confusing to both the user and the translator?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk