Commit f09f3242 by Jonathan Wakely

libstdc++: Reorder declarations of std::span members

I find it easier to work with this class when the declarations match the
order in the C++2a working paper.

There's no need to use long, descriptive template parameter names like
_ContiguousIterator when the parameter is already constrained by the
std::contiguous_iterator concept. This is also consistent with the
naming conventions in the working paper.

	* include/std/span (span): Reorder members and rename template
	parameters to match declarations in the C++2a working paper.
parent f5b4dc38
2020-02-18 Jonathan Wakely <jwakely@redhat.com> 2020-02-18 Jonathan Wakely <jwakely@redhat.com>
* include/std/span (span): Reorder members and rename template
parameters to match declarations in the C++2a working paper.
P2116R0 Remove tuple-like protocol support from fixed-extent span P2116R0 Remove tuple-like protocol support from fixed-extent span
* include/std/span (get, tuple_size, tuple_element): Remove. * include/std/span (get, tuple_size, tuple_element): Remove.
* testsuite/23_containers/span/everything.cc: Remove checks for * testsuite/23_containers/span/everything.cc: Remove checks for
......
...@@ -140,25 +140,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -140,25 +140,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
public: public:
// member types // member types
using value_type = remove_cv_t<_Type>;
using element_type = _Type; using element_type = _Type;
using value_type = remove_cv_t<_Type>;
using size_type = size_t; using size_type = size_t;
using reference = element_type&; using difference_type = ptrdiff_t;
using const_reference = const element_type&;
using pointer = _Type*; using pointer = _Type*;
using const_pointer = const _Type*; using const_pointer = const _Type*;
using iterator using reference = element_type&;
= __gnu_cxx::__normal_iterator<pointer, span>; using const_reference = const element_type&;
using const_iterator using iterator = __gnu_cxx::__normal_iterator<pointer, span>;
= __gnu_cxx::__normal_iterator<const_pointer, span>; using const_iterator = __gnu_cxx::__normal_iterator<const_pointer, span>;
using reverse_iterator = std::reverse_iterator<iterator>; using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>; using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using difference_type = ptrdiff_t;
// member constants // member constants
static inline constexpr size_t extent = _Extent; static constexpr size_t extent = _Extent;
// constructors // constructors, copy and assignment
constexpr constexpr
span() noexcept span() noexcept
...@@ -166,8 +164,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -166,8 +164,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_extent(0), _M_ptr(nullptr) : _M_extent(0), _M_ptr(nullptr)
{ } { }
constexpr template<contiguous_iterator _It>
span(const span&) noexcept = default; requires (__is_compatible_iterator<_It>::value)
constexpr
span(_It __first, size_type __count)
noexcept
: _M_extent(__count), _M_ptr(std::to_address(__first))
{ __glibcxx_assert(_Extent == dynamic_extent || __count == _Extent); }
template<contiguous_iterator _It, sized_sentinel_for<_It> _End>
requires (__is_compatible_iterator<_It>::value)
&& (!is_convertible_v<_End, size_type>)
constexpr
span(_It __first, _End __last)
noexcept(noexcept(__last - __first))
: _M_extent(static_cast<size_type>(__last - __first)),
_M_ptr(std::to_address(__first))
{
if (_Extent != dynamic_extent)
__glibcxx_assert((__last - __first) == _Extent);
}
template<typename _Tp, size_t _ArrayExtent> template<typename _Tp, size_t _ArrayExtent>
requires (__is_compatible_array<_Tp, _ArrayExtent>::value) requires (__is_compatible_array<_Tp, _ArrayExtent>::value)
...@@ -203,27 +219,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -203,27 +219,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: span(ranges::data(__range), ranges::size(__range)) : span(ranges::data(__range), ranges::size(__range))
{ } { }
template<contiguous_iterator _ContiguousIterator, constexpr
sized_sentinel_for<_ContiguousIterator> _Sentinel> span(const span&) noexcept = default;
requires (__is_compatible_iterator<_ContiguousIterator>::value)
&& (!is_convertible_v<_Sentinel, size_type>)
constexpr
span(_ContiguousIterator __first, _Sentinel __last)
noexcept(noexcept(__last - __first))
: _M_extent(static_cast<size_type>(__last - __first)),
_M_ptr(std::to_address(__first))
{
if (_Extent != dynamic_extent)
__glibcxx_assert((__last - __first) == _Extent);
}
template<contiguous_iterator _ContiguousIterator>
requires (__is_compatible_iterator<_ContiguousIterator>::value)
constexpr
span(_ContiguousIterator __first, size_type __count)
noexcept
: _M_extent(__count), _M_ptr(std::to_address(__first))
{ __glibcxx_assert(_Extent == dynamic_extent || __count == _Extent); }
template<typename _OType, size_t _OExtent> template<typename _OType, size_t _OExtent>
requires (_Extent == dynamic_extent || _Extent == _OExtent) requires (_Extent == dynamic_extent || _Extent == _OExtent)
...@@ -233,7 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -233,7 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_extent(__s.size()), _M_ptr(__s.data()) : _M_extent(__s.size()), _M_ptr(__s.data())
{ } { }
// assignment ~span() noexcept = default;
constexpr span& constexpr span&
operator=(const span&) noexcept = default; operator=(const span&) noexcept = default;
...@@ -414,8 +411,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -414,8 +411,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
span(const array<_Type, _ArrayExtent>&) span(const array<_Type, _ArrayExtent>&)
-> span<const _Type, _ArrayExtent>; -> span<const _Type, _ArrayExtent>;
template<contiguous_iterator _Iter, typename _Sentinel> template<contiguous_iterator _Iter, typename _End>
span(_Iter, _Sentinel) span(_Iter, _End)
-> span<remove_reference_t<iter_reference_t<_Iter>>>; -> span<remove_reference_t<iter_reference_t<_Iter>>>;
template<typename _Range> template<typename _Range>
......
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