Boost logo

Boost :

From: Hans Dembinski (hans.dembinski_at_[hidden])
Date: 2021-04-09 14:22:17


> On 9. Apr 2021, at 14:13, Ivica B via Boost <boost_at_[hidden]> wrote:
>
> I am doing a performance C++ work and there is a data structure that we use
> and I think it is very useful even for the general public. Here is the
> description:
>
> Currently, I call it *multivector* (I know there is a data structure with
> the same name, this is a temporary name). It works like this:
>
> You specify all the types you want to hold in your multivector:
>
> multivector<rectangle, circle, triangle> mvect;
>
> Each type is held in a separate std::vector for that type. So in the above
> case, multivector<rectangle, circle, triangle> consists of three
> std::vectors: std::vector<rectangle>, std::vector<circle> and
> std::vector<triangle>.
>
> Now, the magic happens when we use templates to process all three vectors
> at once. Imagine there is a function *draw* for all three types. We can do
> something like this:
>
> mvect.for_each([&](auto& shape) { shape.draw(bitmap); });
>
> The above code generates three for_each loops, for rectangle, circle and
> triangle. Inside the loops it calls the draw method for each type. There is
> no dispatching inside the loops, and the loops are really easy for the
> compiler to optimize (due to their simplicity).

It also sounds like https://www.plflib.org/colony.htm, which is unfortunately not in Boost.


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