Skip to content

<mdspan>: std::extents's CTAD unconditionally constrains argument types to be default-constructible #68671

@hewillk

Description

@hewillk

// Deduction guide for extents
template <class... _IndexTypes>
extents(_IndexTypes...) -> extents<size_t, size_t((_IndexTypes(), dynamic_extent))...>;

..which rejects the following code:

https://godbolt.org/z/47vfGne7s

#include <mdspan>

struct S {
  S(size_t);
  operator size_t() const noexcept;
};

int main() {
  int* p;
  std::mdspan ms(p, S{3}); // ok
  std::extents exts(S{3}); // error
}

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorlibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions