Boost logo

Boost :

From: Helmut Zeisel (HZ2012_at_[hidden])
Date: 2022-01-09 15:44:29


> Von: "Marshall Clow via Boost" <boost_at_[hidden]>
>> On Fri, Jan 7, 2022 at 8:16 AM Helmut Zeisel via Boost <boost_at_[hidden][mailto:boost_at_[hidden]]> wrote:

>>
>> What I have in mind, however, (as I mentioned already ealier) is some general adapter class
>>
>> template<typename T, typename Index, typename Policy>
>> struct array_index_adapter { ... };
>>
>> that can apply different types of indices (row major, column major, triangular ...) to different containers
>> (stack allocated, heap allocated, mixed like boost::small_vector etc).

> You should look at mdspan, then.
> It’s been in use at various national labs for many years, and is being proposed for a future standard.

> A reference implementation is here: https://github.com/kokkos/mdspan

mdspan.hpp has the implementation

   detail::__compressed_pair<pointer, __map_acc_pair_t> __members{};

As I understand, "pointer" is restricted to "true" pointers.
What I have in mind, however, is "container" instead of pointer.
E.g. if "container" is std::vector, it will be a simple multidimensional array.
"container" can still be a plain pointer or a smart pointer (or std::reference_wrapper) to some container; then it will be a view.

Acutally up to some degree this is also discussed in the mdarray proposal

https://isocpp.org/files/papers/D1684R0.html

"2.4.2 Analogs in the Standard Library: Container Adapters"

but for some reason it is restricted to

pointer = Container*;

and not

pointer = Container;

IMHO an adapter can also be done directly for the container itself, not only for a pointer to the container.

Helmut


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