Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-05-27 05:57:15

Alexander Nasonov <alnsn-boost_at_[hidden]> writes:

> Peder Holt <peder.holt <at>> writes:
>> On 5/27/05, Alexander Nasonov <alnsn-boost <at>> wrote:
>> > Sizes may become very huge, though.
>> If you replace your function with:
>> char (&foo())[900][800][700][600];
>> you will get an overflow when calculating e.g. sizeof(foo()) /
>> sizeof(foo()[0]),
>> and the result will be garbage.
> That's right.
> Huge arrays can be replaced with tuples.
> tuple<char(&)[9], char(&)[8], char(&)[7], char(&)[6]> foo();

Why not an mpl::vector for that matter?

It's easy enough to extract each dimension of an array with partial
specialization. Just do the representation backwards:

char (& foo( whatever ) ) [CODEN][CODEN-1]...[CODE1][CODE0]

Steve Dewhurst was here before us.

> sizeof(get<0>(foo())); sizeof(get<1>(foo())); sizeof(get<2>(foo()));
> sizeof(get<3>(foo()));
> Not sure if it compiles with boost::tuple.

Inefficient at compile time. get<N> is O(N) each time, thus the above
is O(N^2); that's part of what's behind the fusion library.

Dave Abrahams
Boost Consulting

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