Boost logo

Boost :

Subject: Re: [boost] Interest in library for nested containers?
From: Alberto Marnetto (alberto.m.dev_at_[hidden])
Date: 2016-01-28 10:12:51


Vee Kay <vkicefire <at> gmail.com> writes:

>
> What would this offer over Boost.MultiArray?
>

My library and Boost.Multidim are actually orthogonal: the latter offers a
specific family of containers, while the former is a collection of
algorithms for generic programming with arbitrary container types.

As an example, say one needs a template function which copies a nested
container of unknown type T into an appropriate boost::multi_array. Using
only STL and Boost this is not easy, as one has to heavily use
metaprogramming to obtain the template parameters of the target multi_array
(scalar type and dimensionality), and then more convolutions with recursion
are needed to actually implement the copy. With multidim the same function
can be written in about 10 lines, as the library provides all the requested
functionalities: dimensionality() and scalarType() to determine the
appropriate multi_array instantiation, bounds() to correctly size it, and
flattening views to copy source to destination with a single 'for' loop.

Here I have somewhat cheated, since I wrote multidim specifically to solve
such kind of problems, but nonetheless I hope to have shown how my code
could add functionality to Boost and cooperate nicely with its
components.

Regards,
Alberto Marnetto


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