Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2003-12-03 12:15:34

On Dec 3, 2003, at 10:29 AM, AlisdairM wrote:

> Well, I'm trying to use dimension in a non-metaprogramming use-case <g>
> We have quite a few places in our codebase where we allow the compiler
> to
> determine array size for us:
> sometype var[] = { initialiser-list };
> Often we need to pass this array to some function or library
> algorithm, and
> then we need the upper bound. This is not readily available from var
> without resorting to
> sizeof(var) / sizeof(var[0]);
> Much nicer to pick it out with
> dimension( var );
> So it's not something that can't be worked around, but going directly
> to
> the answer rather than seeing the calculation and worrying about
> whether
> packing / alignment is an issue etc. simplifies code reviews etc.
> The problem here is obtaining the type of var. Using a function
> template
> allows for type-deduction, but does not yield a compile time constant.

I see. Thanks. The compile-time version of dimension would be more
clumsy for you:


Too clumsy?

> Personally, I would rather use tr1::array for this <g> but again we
> have no
> syntax to deduce array size here so must fall back on traditional C
> arrays.

<shocking!> :-)


Boost list run by bdawes at, gregod at, cpdaniel at, john at