FEniCS / FEniCS/basix

`mdspan` parentheses vs bracket operator

Open
#842 0 comments 0 reactions 0 assignees View on GitHub
housekeeping
Dominant language
C++
Stars
145
Forks
47
Avg merge
3h 5m
Merged PRs (30d)
8

Description

Currently the Kokkos `mdspan` implementation is used in its parentheses mode.

After https://github.com/FEniCS/basix/pull/838 is merged we should, at least in principle, be able to switch to the usage of bracket operators. However, this caused some compile time problems, that were not yet fixed.

For example, the following code does not compile (with gcc version 11.4).

```cpp
#include "mdspan.hpp"

template
using mdspan_t = MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan>;

template
void pass(IndexType... indices)
{
static_assert(sizeof...(IndexType) == 2);
}

void test()
{
mdspan_t span;
static_assert(span.rank() == 2);

std::array indices = {0, 0};
static_assert(indices.size() == 2);
span[indices];

pass(0, 0);

static_assert(std::is_convertible_v::index_type>);
static_assert(std::is_nothrow_constructible_v::index_type, decltype((0,0))>);

span[0, 0]; // but this fails with (rank() == sizeof...(SizeTypes)) evaluating to False
}
```

To circumvent this and allow the increase of the C++ standard in use, we explicitly enforce the use of parentheses by setting the flag `MDSPAN_USE_PAREN_OPERATOR`. This needs to be reverted in after fixing the bracket operator problems.

Note: the necessary syntactical changes from `(...)` to `[...]` may be found at https://github.com/schnellerhase/basix/pull/2.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.