[Boost.] Multi
Disclosure: This is not an official or accepted Boost library and is unrelated to the std::mdspan proposal. It is in the process of being proposed for inclusion in Boost and it doesn't depend on Boost libraries.
© Alfredo A. Correa, 2018-2025
Multi is a modern C++ library that provides manipulation and access of data in multidimensional arrays for both CPU and GPU memory.
#include <boost/multi/array.hpp>
int main() {
    multi::array<int, 2> A {  // two-dimensional array of integers
      {1, 2, 3},
      {4, 5, 6}
    };
    assert( A.size() == 2 );  // the array has 2 rows
    assert( A.size() == A.end() - A.begin() );  // array provides interators to rows
    assert( A[1][1] == 5);  // array provies element access through indexing
    assert( A.elements().size() == 2*3 );  // elements can be accessed as a "flat" sequences
    aseert( A.elements()[4] == 5);  // the "flat" sequence can be accessed by index (and by iterator)
}Before installing the library, you can try it online through the Godbolt's Compiler Explorer.
Multi has no external dependencies and can be used immediately after downloading.
git clone https://gitlab.com/correaa/boost-multi.gitMulti doesn't require installation since a single header is enough to use the entire core library;
#include <multi/array.hpp>
int main() { ... }The library can be also installed with CMake.
The header (and CMake) files will be installed in the chosen prefix location (by default, /usr/local/include/multi and /usr/local/share/multi).
cd boost-multi
mkdir -p build && cd build
cmake . -B ./build  # --install-prefix=$HOME/.local
cmake --install ./build  # or sudo ...Testing the library requires Boost.Core (headers), installed for example, via sudo apt install cmake git g++ libboost-test-dev make or sudo dnf install boost-devel cmake gcc-c++ git.
A CMake build system is provided to compile and run basic tests.
ctest -C ./buildOnce installed, other CMake projects (targets) can depend on Multi by adding a simple add_subdirectory(my_multi_path) or by find_package:
find_package(multi)  # see https://gitlab.com/correaa/boost-multiAlternatively, the library can be fetched on demand:
include(FetchContent)
FetchContent_Declare(multi GIT_REPOSITORY https://gitlab.com/correaa/boost-multi.git)
FetchContent_MakeAvailable(multi)
...
target_link_libraries(my_target PUBLIC multi)- File a Gitlab issue or Github issue.
 - Join the #boost-multi discussion group at cpplang.slack.com