From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1984) id 4C39C393BC3F; Fri, 17 Jul 2020 13:11:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C39C393BC3F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594991465; bh=Ogkjl+8/4JaVqMkdnreyT6DG2E4Bv3mTqI84Er4fL4Q=; h=From:To:Subject:Date:From; b=wRfNXHSP0cwbS0Sk3ZuMTxNFzKrF3ivNZwzT1MqdKHGaa5YWM4905xLLWoWfuJQTZ B9r84WOxo9jFTd7Xf+eEywGlpGvDn/xejbeh8SOEWDgv/dFOisD94go2e3bFho83Sk ELPZlSvey7sFU/ZJwQAqXwKHMj10B9HWGdUhnfzM= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tamar Christina To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/arm-perf-staging)] libstdc++: Fix and simplify constraints on std::span constructors X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/vendors/ARM/heads/arm-perf-staging X-Git-Oldrev: f09f32427b21127af0ec4c4a48dc9f3b0e696e59 X-Git-Newrev: d6c9e372372ee78283a21651313fce965d22274d Message-Id: <20200717131105.4C39C393BC3F@sourceware.org> Date: Fri, 17 Jul 2020 13:11:05 +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: Fri, 17 Jul 2020 13:11:05 -0000 https://gcc.gnu.org/g:d6c9e372372ee78283a21651313fce965d22274d commit d6c9e372372ee78283a21651313fce965d22274d Author: Jonathan Wakely Date: Tue Feb 18 13:12:44 2020 +0000 libstdc++: Fix and simplify constraints on std::span constructors This makes the constraints consistent with the pre-Prague working paper. * include/std/span (span::__is_compatible_array): Simplify alias template by using requires-clause. (span::__is_compatible_ref): New alias template for constraining constructors. (span::__is_compatible_iterator, span::__is_compatible_range): Remove. (span(It, size_type), span(It, End)): Use __is_compatible_ref. (span(T(&)[N], span(array&), span(const array&)): Remove redundant parentheses. (span(R&&)): Add missing constraints. Diff: --- libstdc++-v3/ChangeLog | 10 ++++++++++ libstdc++-v3/include/std/span | 38 ++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6ae3955d2ce..de0995264a0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,15 @@ 2020-02-18 Jonathan Wakely + * include/std/span (span::__is_compatible_array): Simplify alias + template by using requires-clause. + (span::__is_compatible_ref): New alias template for constraining + constructors. + (span::__is_compatible_iterator, span::__is_compatible_range): Remove. + (span(It, size_type), span(It, End)): Use __is_compatible_ref. + (span(T(&)[N], span(array&), span(const array&)): Remove + redundant parentheses. + (span(R&&)): Add missing constraints. + * include/std/span (span): Reorder members and rename template parameters to match declarations in the C++2a working paper. diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span index feb1c1f46ad..21114f1e038 100644 --- a/libstdc++-v3/include/std/span +++ b/libstdc++-v3/include/std/span @@ -123,20 +123,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3255. span's array constructor is too strict template - using __is_compatible_array = __and_< - bool_constant<(_Extent == dynamic_extent || _ArrayExtent == _Extent)>, - __is_array_convertible<_Type, _Tp>>; + requires (_Extent == dynamic_extent || _ArrayExtent == _Extent) + using __is_compatible_array = __is_array_convertible<_Type, _Tp>; - template> - using __is_compatible_iterator = __and_< - bool_constant>, - is_lvalue_reference>, - is_same, remove_cvref_t<_Ref>>, - __is_array_convertible<_Type, remove_reference_t<_Ref>>>; - - template - using __is_compatible_range - = __is_compatible_iterator>; + template + using __is_compatible_ref + = __is_array_convertible<_Type, remove_reference_t<_Ref>>; public: // member types @@ -165,7 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { } template - requires (__is_compatible_iterator<_It>::value) + requires __is_compatible_ref>::value constexpr span(_It __first, size_type __count) noexcept @@ -173,8 +165,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { __glibcxx_assert(_Extent == dynamic_extent || __count == _Extent); } template _End> - requires (__is_compatible_iterator<_It>::value) - && (!is_convertible_v<_End, size_type>) + requires __is_compatible_ref>::value + && (!is_convertible_v<_End, size_type>) constexpr span(_It __first, _End __last) noexcept(noexcept(__last - __first)) @@ -186,32 +178,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template - requires (__is_compatible_array<_Tp, _ArrayExtent>::value) + requires __is_compatible_array<_Tp, _ArrayExtent>::value constexpr span(_Tp (&__arr)[_ArrayExtent]) noexcept : span(static_cast(__arr), _ArrayExtent) { } template - requires (__is_compatible_array<_Tp, _ArrayExtent>::value) + requires __is_compatible_array<_Tp, _ArrayExtent>::value constexpr span(array<_Tp, _ArrayExtent>& __arr) noexcept : span(static_cast(__arr.data()), _ArrayExtent) { } template - requires (__is_compatible_array::value) + requires __is_compatible_array::value constexpr span(const array<_Tp, _ArrayExtent>& __arr) noexcept : span(static_cast(__arr.data()), _ArrayExtent) { } - template + template requires (_Extent == dynamic_extent) + && ranges::contiguous_range<_Range> && ranges::sized_range<_Range> + && (ranges::safe_range<_Range> || is_const_v) && (!__detail::__is_std_span>::value) && (!__detail::__is_std_array>::value) - && (!is_array_v>) - && (__is_compatible_range<_Range>::value) + && (!is_array_v>) + && __is_compatible_ref>::value constexpr span(_Range&& __range) noexcept(noexcept(ranges::data(__range))