mdspan icon indicating copy to clipboard operation
mdspan copied to clipboard

Breaking changes due to C++ committee review

Open crtrott opened this issue 3 years ago • 6 comments

Hi all,

there are a number of breaking changes upcoming which stem from the intense review mdspan got now that its is nearing inclusion into the C++23 standard. These are described in P2553, P2554, P2604 and P2599.

All of these changes are getting merged into P0009 (the main mdspan paper) as part of the final wording review in LWG.

We created an mdspan-0.3.0 tag before any of this hits the repo.

Extents gets a controllable integral type

https://wg21.link/p2553

This allows (and makes it mandatory) for a user to choose what the underlying integral type is for extents, a type which can be unsigned or signed.

Before:

template<size_t ... Extents>
class extents;

After

template<class IndexType, size_t ... Extents>
class extents;

Fix up deduction guide from 1D c-arrays.

https://wg21.link/p2554

This changes the behavior of the deduction guide then, constructing from a carray which is convertable to pointer.

Before:

int data[6];
mdspan a(data);
static_assert(a.rank()==0);

mdspan b(data,2,3);
static_assert(b.rank()==2);

After:

int data[6];
mdspan a(data);
static_assert(a.rank()==1);
static_assert(a.static_extents(1)==6);

mdspan b(data,2,3);
static_assert(b.rank()==2);

Renamed members

https://isocpp.org/files/papers/P2604R0.html and https://isocpp.org/files/papers/P2599R1.pdf

  • extents
    • size_type -> index_type
  • mappings:
    • size_type -> index_type
    • is_contiguous -> is_exhaustive
    • is_always_contiguous -> is_always_exhaustive
  • accessors:
    • pointer -> data_handle_type
  • mdspan
    • size_type -> index_type
    • pointer -> data_handle_type
    • data() -> data_handle
    • is_contiguous -> is_exhaustive
    • is_always_contiguous -> is_always_exhaustive

crtrott avatar Jun 16 '22 20:06 crtrott

P2553 and P2554 are now fully integrated into reference implementation. The renamings are not yet done however.

crtrott avatar Jun 23 '22 16:06 crtrott

There is a mdspan-0.4.0 tag which has P2553 and P2554 merged, while stable branch has now the renames done.

crtrott avatar Jun 30 '22 15:06 crtrott

All relevant papers were approved for C++23 inclusion. The only two missing things in the implementation we are aware of are the empty() function and the swap specialization. Everything else should reflect the status of the merged papers. We will add an option to turn on strict C++23 mode - i.e. only enable things actually voted into C++23 - which does not (for running out of review time reasons) include submdspan. The design of mdarray is also still a bit in flux, in particular with respect to which constructors it should have.

crtrott avatar Jul 26 '22 04:07 crtrott

I would like to confirm which version/tag is currently hosted in conan.io as mdspan 0.1.0? It seems there's no dextents alias there.

Is there any plan to update latest version to conan? thanks

zhuoqiang avatar Nov 04 '22 23:11 zhuoqiang

@crtrott Do we maintain a conan.io thing? That's the first time I've heard of mdspan in conan : - )

mhoemmen avatar Nov 07 '22 16:11 mhoemmen

I don't even know what conan is ...

I am planning to tag a new release soon as 1.0. Just working through some outstanding issues.

crtrott avatar Nov 22 '22 17:11 crtrott