From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 35E97395B826; Wed, 17 Jun 2020 18:59:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35E97395B826 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592420353; bh=W6x6N9IUtSV5FJVTzz1B/g06lJDOUBjcXB31l6u+wWE=; h=From:To:Subject:Date:From; b=hO4PuZSLH8Ae8C1pnmbZI3VufSUlpyEewj7fFXnwVLV8QC8RK/yVdNwbQlc29qCyi 4bRINrSnlgDNjRpMCASEbV76JHYkrLF1z2+hKbkwnYWYRmtc2DFYfiOHBO0dwkJznS Ct53LeWwBWgQSSgn9IpkUeydRP1EFdkoBAYSj5nU= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc/devel/ranger] libstdc++: Reorder declarations of std::span members X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/devel/ranger X-Git-Oldrev: f5b4dc38852f755de9c48cb78a773ab4e84b8078 X-Git-Newrev: f09f32427b21127af0ec4c4a48dc9f3b0e696e59 Message-Id: <20200617185913.35E97395B826@sourceware.org> Date: Wed, 17 Jun 2020 18:59:13 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2020 18:59:13 -0000 https://gcc.gnu.org/g:f09f32427b21127af0ec4c4a48dc9f3b0e696e59 commit f09f32427b21127af0ec4c4a48dc9f3b0e696e59 Author: Jonathan Wakely Date: Tue Feb 18 12:33:07 2020 +0000 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. Diff: --- libstdc++-v3/ChangeLog | 3 ++ libstdc++-v3/include/std/span | 69 +++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 75346953416..6ae3955d2ce 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,8 @@ 2020-02-18 Jonathan Wakely + * 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 * include/std/span (get, tuple_size, tuple_element): Remove. * testsuite/23_containers/span/everything.cc: Remove checks for diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span index b8d5e0797a2..feb1c1f46ad 100644 --- a/libstdc++-v3/include/std/span +++ b/libstdc++-v3/include/std/span @@ -140,25 +140,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION public: // member types - using value_type = remove_cv_t<_Type>; using element_type = _Type; + using value_type = remove_cv_t<_Type>; using size_type = size_t; - using reference = element_type&; - using const_reference = const element_type&; + using difference_type = ptrdiff_t; using pointer = _Type*; using const_pointer = const _Type*; - using iterator - = __gnu_cxx::__normal_iterator; - using const_iterator - = __gnu_cxx::__normal_iterator; + using reference = element_type&; + using const_reference = const element_type&; + using iterator = __gnu_cxx::__normal_iterator; + using const_iterator = __gnu_cxx::__normal_iterator; using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; - using difference_type = ptrdiff_t; // member constants - static inline constexpr size_t extent = _Extent; + static constexpr size_t extent = _Extent; - // constructors + // constructors, copy and assignment constexpr span() noexcept @@ -166,8 +164,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _M_extent(0), _M_ptr(nullptr) { } - constexpr - span(const span&) noexcept = default; + template + 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 _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(__last - __first)), + _M_ptr(std::to_address(__first)) + { + if (_Extent != dynamic_extent) + __glibcxx_assert((__last - __first) == _Extent); + } template requires (__is_compatible_array<_Tp, _ArrayExtent>::value) @@ -203,27 +219,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : span(ranges::data(__range), ranges::size(__range)) { } - template _Sentinel> - 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(__last - __first)), - _M_ptr(std::to_address(__first)) - { - if (_Extent != dynamic_extent) - __glibcxx_assert((__last - __first) == _Extent); - } - - template - 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); } + constexpr + span(const span&) noexcept = default; template requires (_Extent == dynamic_extent || _Extent == _OExtent) @@ -233,7 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _M_extent(__s.size()), _M_ptr(__s.data()) { } - // assignment + ~span() noexcept = default; constexpr span& operator=(const span&) noexcept = default; @@ -414,8 +411,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION span(const array<_Type, _ArrayExtent>&) -> span; - template - span(_Iter, _Sentinel) + template + span(_Iter, _End) -> span>>; template