Commit f5b4dc38 by Jonathan Wakely

libstdc++: P2116R0 Remove tuple-like protocol support from fixed-extent span

Following this change it's no longer possible to use std::span with
structured bindings or with the tuple-like API. It will probably come
back for C++23 though.

	P2116R0 Remove tuple-like protocol support from fixed-extent span
	* include/std/span (get, tuple_size, tuple_element): Remove.
	* testsuite/23_containers/span/everything.cc: Remove checks for
	tuple-like API.
	* testsuite/23_containers/span/get_neg.cc: Remove.
	* testsuite/23_containers/span/tuple_element_dynamic_neg.cc: Remove.
	* testsuite/23_containers/span/tuple_element_oob_neg.cc: Remove.
	* testsuite/23_containers/span/tuple_size_neg.cc: Remove.
parent aa667c3f
2020-02-18 Jonathan Wakely <jwakely@redhat.com>
P2116R0 Remove tuple-like protocol support from fixed-extent span
* include/std/span (get, tuple_size, tuple_element): Remove.
* testsuite/23_containers/span/everything.cc: Remove checks for
tuple-like API.
* testsuite/23_containers/span/get_neg.cc: Remove.
* testsuite/23_containers/span/tuple_element_dynamic_neg.cc: Remove.
* testsuite/23_containers/span/tuple_element_oob_neg.cc: Remove.
* testsuite/23_containers/span/tuple_size_neg.cc: Remove.
2020-02-17 Patrick Palka <ppalka@redhat.com>
P2106R0 Alternative wording for GB315 and GB316
......
......@@ -440,36 +440,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return {reinterpret_cast<byte*>(__sp.data()), __sp.size_bytes()};
}
// tuple helpers
template<size_t _Index, typename _Type, size_t _Extent>
constexpr _Type&
get(span<_Type, _Extent> __sp) noexcept
{
static_assert(_Extent != dynamic_extent && _Index < _Extent,
"get<I> can only be used with a span of non-dynamic (fixed) extent");
return __sp[_Index];
}
template<typename _Tp> struct tuple_size;
template<size_t __i, typename _Tp> struct tuple_element;
template<typename _Type, size_t _Extent>
struct tuple_size<span<_Type, _Extent>>
: public integral_constant<size_t, _Extent>
{
static_assert(_Extent != dynamic_extent, "tuple_size can only "
"be used with a span of non-dynamic (fixed) extent");
};
template<size_t _Index, typename _Type, size_t _Extent>
struct tuple_element<_Index, span<_Type, _Extent>>
{
static_assert(_Extent != dynamic_extent, "tuple_element can only "
"be used with a span of non-dynamic (fixed) extent");
static_assert(_Index < _Extent, "Index is less than Extent");
using type = _Type;
};
namespace ranges
{
template<typename> extern inline const bool enable_safe_range;
......
......@@ -104,8 +104,6 @@ main()
static_assert(data_span_first.size() == 3);
static_assert(data_span_first.front() == 0);
static_assert(data_span_first.back() == 2);
static_assert(std::tuple_size_v<decltype(data_span_first)> == 3);
static_assert(std::is_same_v<std::tuple_element_t<0, decltype(data_span_first)>, const int>);
constexpr auto data_span_first_dyn = data_span.first(4);
static_assert(
......@@ -122,8 +120,6 @@ main()
static_assert(data_span_last.size() == 5);
static_assert(data_span_last.front() == 4);
static_assert(data_span_last.back() == 8);
static_assert(std::tuple_size_v<decltype(data_span_last)> == 5);
static_assert(std::is_same_v<std::tuple_element_t<0, decltype(data_span_last)>, const int>);
constexpr auto data_span_last_dyn = data_span.last(6);
static_assert(
......
// Copyright (C) 2019-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=c++2a" }
// { dg-do compile { target c++2a } }
#include <span>
#include <tuple>
int
main()
{
std::span<int, std::dynamic_extent> myspan((int*)nullptr, (std::size_t)0);
std::get<0>(myspan); // { dg-error "here" }
}
// { dg-error "static assertion failed" "" { target *-*-* } 0 }
// Copyright (C) 2019-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=c++2a" }
// { dg-do compile { target c++2a } }
#include <span>
#include <tuple>
std::tuple_element<0, std::span<int, std::dynamic_extent>> ts; // { dg-error "here" }
// { dg-error "static assertion failed" "" { target *-*-* } 0 }
// Copyright (C) 2019-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=c++2a" }
// { dg-do compile { target c++2a } }
#include <span>
#include <tuple>
std::tuple_element<3, std::span<int, 2>> te; // { dg-error "here" }
// { dg-error "static assertion failed" "" { target *-*-* } 0 }
// Copyright (C) 2019-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=c++2a" }
// { dg-do compile { target c++2a } }
#include <span>
#include <tuple>
std::tuple_size<std::span<int, std::dynamic_extent>> ts; // { dg-error "here" }
// { dg-error "static assertion failed" "" { target *-*-* } 0 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment