зеркало из https://github.com/microsoft/STL.git
P2116R0 Removing tuple-Like Protocol Support From Fixed-Extent span (#587)
Fixes #556.
This commit is contained in:
Родитель
f2a03821e2
Коммит
d8b5008ea3
33
stl/inc/span
33
stl/inc/span
|
@ -710,39 +710,6 @@ _NODISCARD auto as_writable_bytes(span<_Ty, _Extent> _Sp) noexcept {
|
|||
}
|
||||
#endif // __cpp_lib_byte
|
||||
|
||||
// [span.tuple] Tuple interface
|
||||
#ifdef __cpp_lib_concepts
|
||||
|
||||
// clang-format off
|
||||
template <class _Ty, size_t _Extent>
|
||||
requires (_Extent != dynamic_extent)
|
||||
struct tuple_size<span<_Ty, _Extent>> : integral_constant<size_t, _Extent> {};
|
||||
// clang-format on
|
||||
|
||||
#else // ^^^ __cpp_lib_concepts / !__cpp_lib_concepts vvv
|
||||
|
||||
template <class _Ty, size_t _Extent>
|
||||
struct tuple_size<span<_Ty, _Extent>> : integral_constant<size_t, _Extent> {};
|
||||
|
||||
template <class _Ty>
|
||||
struct tuple_size<span<_Ty, dynamic_extent>>;
|
||||
|
||||
#endif // !__cpp_lib_concepts
|
||||
|
||||
template <size_t _Index, class _Ty, size_t _Extent>
|
||||
struct _MSVC_KNOWN_SEMANTICS tuple_element<_Index, span<_Ty, _Extent>> {
|
||||
static_assert(dynamic_extent != _Extent, "std::span<T, dynamic_extent> is not tuple-like");
|
||||
static_assert(_Index < _Extent, "Index out of bounds for a std::span of this extent");
|
||||
using type = _Ty;
|
||||
};
|
||||
|
||||
template <size_t _Index, class _Ty, size_t _Extent>
|
||||
_NODISCARD constexpr _Ty& get(span<_Ty, _Extent> _Span) noexcept {
|
||||
static_assert(dynamic_extent != _Extent, "std::get<> not supported for std::span<T, dynamic_extent>");
|
||||
static_assert(_Index < _Extent, "Index out of bounds for a std::span of this extent");
|
||||
return _Span[_Index];
|
||||
}
|
||||
|
||||
_STD_END
|
||||
|
||||
#pragma pop_macro("new")
|
||||
|
|
|
@ -199,6 +199,7 @@
|
|||
// P1976R2 Explicit Constructors For Fixed-Extent span From Dynamic-Extent Ranges
|
||||
// P2091R0 Fixing Issues With Range Access CPOs
|
||||
// P2102R0 Making "Implicit Expression Variations" More Explicit
|
||||
// P2116R0 Removing tuple-Like Protocol Support From Fixed-Extent span
|
||||
// P????R? directory_entry::clear_cache()
|
||||
|
||||
// _HAS_CXX20 indirectly controls:
|
||||
|
|
|
@ -692,6 +692,14 @@ language.support\support.limits\support.limits.general\string.version.pass.cpp
|
|||
# Test needs to be updated for LWG-3320 removing span::const_iterator.
|
||||
containers\views\types.pass.cpp
|
||||
|
||||
# Test needs to be updated for P2116R0 removing the tuple interface of span
|
||||
containers\views\span.tuple\get.fail.cpp
|
||||
containers\views\span.tuple\get.pass.cpp
|
||||
containers\views\span.tuple\tuple_element.fail.cpp
|
||||
containers\views\span.tuple\tuple_element.pass.cpp
|
||||
containers\views\span.tuple\tuple_size.fail.cpp
|
||||
containers\views\span.tuple\tuple_size.pass.cpp
|
||||
|
||||
# Test bug. See LWG-3099 "is_assignable<Incomplete&, Incomplete&>"
|
||||
utilities\utility\pairs\pairs.pair\assign_pair.pass.cpp
|
||||
|
||||
|
|
|
@ -79,15 +79,6 @@ static_assert(ranges::enable_borrowed_range<span<int>>);
|
|||
static_assert(ranges::enable_borrowed_range<span<int, 3>>);
|
||||
#endif // __cpp_lib_concepts
|
||||
|
||||
static_assert(is_base_of_v<integral_constant<size_t, 3>, tuple_size<span<int, 3>>>);
|
||||
static_assert(is_base_of_v<integral_constant<size_t, 3>, tuple_size<const span<int, 3>>>);
|
||||
|
||||
// LWG-3378: <span> isn't guaranteed to provide tuple_element_t; our implementation does.
|
||||
static_assert(is_same_v<tuple_element_t<2, span<int, 3>>, int>);
|
||||
static_assert(is_same_v<tuple_element_t<2, const span<int, 3>>, const int>);
|
||||
static_assert(is_same_v<tuple_element_t<2, span<const int, 3>>, const int>);
|
||||
static_assert(is_same_v<tuple_element_t<2, const span<const int, 3>>, const int>);
|
||||
|
||||
// For performance, our implementation provides an additional guarantee beyond the Standard
|
||||
// that span and its iterator types are trivially copyable.
|
||||
static_assert(is_trivially_copyable_v<span<int>>);
|
||||
|
@ -1019,20 +1010,6 @@ constexpr bool test() {
|
|||
static_assert(is_same_v<decltype(sp_nine.rbegin()), span<int, 9>::reverse_iterator>);
|
||||
static_assert(is_same_v<decltype(sp_dyn.rend()), span<int>::reverse_iterator>);
|
||||
static_assert(is_same_v<decltype(sp_nine.rend()), span<int, 9>::reverse_iterator>);
|
||||
|
||||
static_assert(noexcept(get<5>(sp_nine)));
|
||||
assert(get<5>(sp_nine) == 60);
|
||||
assert(&get<5>(sp_nine) == begin(sequence) + 5);
|
||||
}
|
||||
|
||||
{
|
||||
span<int, 3> sp_three(arr);
|
||||
|
||||
auto& [x, y, z] = sp_three;
|
||||
|
||||
assert(&x == begin(arr));
|
||||
assert(&y == begin(arr) + 1);
|
||||
assert(&z == begin(arr) + 2);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Загрузка…
Ссылка в новой задаче