Found while running libc++'s test suite with MSVC's STL. [mdspan.extents.overview]/1.1 mandates that IndexType is a signed or unsigned integer type, which excludes char. MSVC's STL enforces the Mandates here, so this PR changes the relevant occurrences of `char to `signed char`. To make this work, we also need to add an `operator signed char()` to the test helper type `IntType` so it remains unambiguously convertible, and then we can remove `operator char()`. libc++ should also enforce the Mandates, but this PR doesn't attempt to make such a change.
34 lines
1.2 KiB
C++
34 lines
1.2 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
|
|
|
|
// <mdspan>
|
|
|
|
// template<class Extents>
|
|
// class layout_left::mapping;
|
|
|
|
// If Extents is not a specialization of extents, then the program is
|
|
// ill-formed.
|
|
|
|
// Mandates: If Extents::rank_dynamic() == 0 is true, then the size of the
|
|
// multidimensional index space Extents() is representable as a value of type
|
|
// typename Extents::index_type.
|
|
|
|
#include <mdspan>
|
|
|
|
void not_extents() {
|
|
// expected-error-re@*:* {{static assertion failed {{.*}}layout_left::mapping template argument must be a specialization of extents}}
|
|
[[maybe_unused]] std::layout_left::mapping<void> mapping;
|
|
}
|
|
|
|
void representable() {
|
|
// expected-error-re@*:* {{static assertion failed {{.*}}layout_left::mapping product of static extents must be representable as index_type.}}
|
|
[[maybe_unused]] std::layout_left::mapping<std::extents<signed char, 20, 20>> mapping;
|
|
}
|