|
Boost : |
From: Giovanni Bavestrelli (gibav_at_[hidden])
Date: 2000-12-02 07:09:59
--- In boost_at_[hidden], "William Kempf" <sirwillard_at_m...> wrote:
> --- In boost_at_[hidden], "Giovanni Bavestrelli" <gibav_at_y...> wrote:
> > --- In boost_at_[hidden], Kevlin Henney <kevlin_at_c...> wrote:
> > > In message <906dth+ds3m_at_e...>, William Kempf <sirwillard_at_my-
> > > deja.com> writes
> > > >
> > > >Array<int, 3> A3(dim(10) + dim(20) + dim(30));
> > >
> > 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?
>
> Yes, but the syntax is alien to anything else. Why not:
>
> Array<int, 3> A3(dimensions(10, 20, 30));
>
> where 'dimensions' is a factory function that creates the same type
> that 'dim(10)(20)(30)' did?
So far, this is the idea that looks the nicest to me. I do not much
like the ideas of overloading operators that came previously. But
would it be possible to make a factory function that works with any
number of dimensions, so with any number of parameters, and returns
the appropriate type for each of them? I would not like to limit the
number of dimensions, for example by providing 10 factory functions
for the first 10 dimensions, and putting a limit to the number of
dimensions.
Anyway, my class ArraySizes that passes the number of dimensions is
just an add-on to the multidimensional Array class, it's not
necessary at all, you can use:
unsigned in Size[]={10,20,30};
Array<int, 3> A3(Size);
Does anyone have ideas on the rest of the multidimensional Array? Any
suggestions for the main classes Array and SubArray (or RefArray, as
I renamed them in the downloadable code)?
Thanks
Giovanni Bavestrelli
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk