Boost logo

Boost :

From: Giovanni Bavestrelli (gibav_at_[hidden])
Date: 2000-12-01 17:01:43


--- In boost_at_[hidden], Kevlin Henney <kevlin_at_c...> wrote:
> In message <906dth+ds3m_at_e...>, William Kempf <sirwillard_at_my-
> deja.com> writes
> >> Where X is an appropriate but short name we haven't yet thought
of
> >that
> >> indicates dimension :->
> >
> >Array<int, 3> A3(dim(10) + dim(20) + dim(30));
>
> I had been hoping to avoid the obvious BASIC reference, but I must
> confess that it has a certain appeal.
>

This has a certain appeal to me, and at first sight it does not look
difficult to implement, maintaining the type safety that would make
it impossible to pass the wrong number of dimensions to the
constructor. But, keeping the class name you suggested, my approach
would become:

Array<int, 3> A3(dim(10)(20)(30));

Is it not more concise? Besides, not overloading operator + would
probably make it less open to abuse. And, using your approach, what
about:

Array<int, 3> A3((dim(10) + dim(20)) + dim(30));

Should that work? It certainly does not look nice to me. Another
consideration: we are not adding dimensions, if anything, we are
multiplying them, so should we overload operator *? All in all, I'm
not convinced.

> >Or even:
> >
> >Array<int, 3> A3(dim(10), dim(20), dim(30));
> >
> >by overloading the comma operator?
>

This looks better, but it's still not as concise.

> It would have to be
>
> Array<int, 3> A3((dim(10), dim(20), dim(30));
>

I don't like those extra brackets.

> And even then, I feel a little uncomfortable overloading the comma
> operator in public :-}
>

I agree.

> Kevlin

Thanks for your ideas!

Giovanni

> ____________________________________________________________
>
> Kevlin Henney phone: +44 117 942 2990
> Curbralan Limited mobile: +44 7801 073 508
> mailto:kevlin_at_c... fax: +44 870 052 2289
> http://www.curbralan.com
> ____________________________________________________________


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