Describe the bug
std::mdspan accepts a reference type as its ElementType.
Reproduction
#include <mdspan>
struct BadAccessor {
using offset_policy = BadAccessor;
using element_type = int&;
using reference = int&;
using data_handle_type = int*;
reference access(data_handle_type p, std::size_t i) const {
return p[i];
}
};
int main() {
std::mdspan<int&, std::dextents<int, 2>, std::layout_right, BadAccessor> m;
}
Expected behavior
According to [mdspan.mdspan.overview]
ElementType is a complete object type that is neither an abstract class type nor an array type,
The program should be rejected as ill-formed.
STL version
202508
Additional context
libstdc++ and libc++ also accept this.
https://godbolt.org/z/PeP6beWWb
Describe the bug
std::mdspanaccepts a reference type as itsElementType.Reproduction
Expected behavior
According to [mdspan.mdspan.overview]
The program should be rejected as ill-formed.
STL version
202508
Additional context
libstdc++ and libc++ also accept this.
https://godbolt.org/z/PeP6beWWb