public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Tamar Christina <tnfchris@gcc.gnu.org> 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 Date: Fri, 17 Jul 2020 13:11:05 +0000 (GMT) [thread overview] Message-ID: <20200717131105.4C39C393BC3F@sourceware.org> (raw) https://gcc.gnu.org/g:d6c9e372372ee78283a21651313fce965d22274d commit d6c9e372372ee78283a21651313fce965d22274d Author: Jonathan Wakely <jwakely@redhat.com> 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<T, N>&), span(const array<T, N>&)): 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 <jwakely@redhat.com> + * 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<T, N>&), span(const array<T, N>&)): 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<typename _Tp, size_t _ArrayExtent> - 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<typename _Iter, typename _Ref = iter_reference_t<_Iter>> - using __is_compatible_iterator = __and_< - bool_constant<contiguous_iterator<_Iter>>, - is_lvalue_reference<iter_reference_t<_Iter>>, - is_same<iter_value_t<_Iter>, remove_cvref_t<_Ref>>, - __is_array_convertible<_Type, remove_reference_t<_Ref>>>; - - template<typename _Range> - using __is_compatible_range - = __is_compatible_iterator<ranges::iterator_t<_Range>>; + template<typename _Ref> + using __is_compatible_ref + = __is_array_convertible<_Type, remove_reference_t<_Ref>>; public: // member types @@ -165,7 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { } template<contiguous_iterator _It> - requires (__is_compatible_iterator<_It>::value) + requires __is_compatible_ref<iter_reference_t<_It>>::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<contiguous_iterator _It, sized_sentinel_for<_It> _End> - requires (__is_compatible_iterator<_It>::value) - && (!is_convertible_v<_End, size_type>) + requires __is_compatible_ref<iter_reference_t<_It>>::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<typename _Tp, size_t _ArrayExtent> - requires (__is_compatible_array<_Tp, _ArrayExtent>::value) + requires __is_compatible_array<_Tp, _ArrayExtent>::value constexpr span(_Tp (&__arr)[_ArrayExtent]) noexcept : span(static_cast<pointer>(__arr), _ArrayExtent) { } template<typename _Tp, size_t _ArrayExtent> - requires (__is_compatible_array<_Tp, _ArrayExtent>::value) + requires __is_compatible_array<_Tp, _ArrayExtent>::value constexpr span(array<_Tp, _ArrayExtent>& __arr) noexcept : span(static_cast<pointer>(__arr.data()), _ArrayExtent) { } template<typename _Tp, size_t _ArrayExtent> - requires (__is_compatible_array<const _Tp, _ArrayExtent>::value) + requires __is_compatible_array<const _Tp, _ArrayExtent>::value constexpr span(const array<_Tp, _ArrayExtent>& __arr) noexcept : span(static_cast<pointer>(__arr.data()), _ArrayExtent) { } - template<ranges::contiguous_range _Range> + template<typename _Range> requires (_Extent == dynamic_extent) + && ranges::contiguous_range<_Range> && ranges::sized_range<_Range> + && (ranges::safe_range<_Range> || is_const_v<element_type>) && (!__detail::__is_std_span<remove_cvref_t<_Range>>::value) && (!__detail::__is_std_array<remove_cvref_t<_Range>>::value) - && (!is_array_v<remove_reference_t<_Range>>) - && (__is_compatible_range<_Range>::value) + && (!is_array_v<remove_cvref_t<_Range>>) + && __is_compatible_ref<ranges::range_reference_t<_Range>>::value constexpr span(_Range&& __range) noexcept(noexcept(ranges::data(__range))
reply other threads:[~2020-07-17 13:11 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200717131105.4C39C393BC3F@sourceware.org \ --to=tnfchris@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).