Boost logo

Boost :

From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2020-01-24 16:18:02


> Alexander wrote:
>> So if T[] and T[N] are valid, then T[N][M] should also be. This increases
> the scope greatly but has an incredible difficult questions to answer: What
> would operator[] return? I don't have a good answer...
>
> Simple questions that already have an answer:
> The same way shared_ptr<T[N][M]> works today. :)
>
> Its operator[] returns element_type&
>
> So:
> auto p = allocate_shared<int[5][1024]>(alloc);
> p[3][675] = 8;
>
> auto q = allocate_unique<double[][2][3][4]>(alloc, size);
> q[index][1][1][1] = 0.95;
>
> Then:
> dynamic<int[5][1024], Allocator> a(alloc);
> a[3][675] = 8;
>
> i.e. Making it work for T[N] also automatically makes it work for T[N][M].

Sure, but shouldn't `Foo<T[N][M]>[]` return `Foo<T[N]>` so you can pass
it down like that? Sure returning basically a raw array is possible and
easiest, but you (may) loose the goodies for type/range checking and you
can't get a lower-D type out of a high-D type for passing that down an
interface.




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