From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108756 invoked by alias); 24 Feb 2020 12:16:26 -0000 Mailing-List: contact libstdc++-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libstdc++-owner@gcc.gnu.org Received: (qmail 108706 invoked by uid 89); 24 Feb 2020 12:16:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Feb 2020 12:16:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582546570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=7JUmORp/NoCtvWskqXOWbpgApeYf4ngV24xMw1oCWQY=; b=EgJPJxMpVL/XRzrHsfIqKugiENQe7iRHQ/quKEctxL0jUVjfGSaGYjt2GQCv1FP336NCMW 56Qe74KKTQHNpgZtC02Q0y5w4yCXBzWkT3G/QTU6f3yGb436kttLg0Qyly3aspm+lBUtzP 6FuF1wwdt5n0iiEOpb3cV7BRHmSYw48= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-337-DaT521SrMpS8fyRof7-kCA-1; Mon, 24 Feb 2020 07:16:07 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4444107ACC9; Mon, 24 Feb 2020 12:16:06 +0000 (UTC) Received: from localhost (unknown [10.33.36.96]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E4AC5C21B; Mon, 24 Feb 2020 12:16:06 +0000 (UTC) Date: Mon, 24 Feb 2020 12:16:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: enable_view has false positives (LWG 3326) Message-ID: <20200224121605.GA2095381@redhat.com> MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="gKMricLos+KVdGMg" Content-Disposition: inline X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00149.txt.bz2 --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 946 * include/std/ranges (__deep_const_range, __enable_view_impl): Remove. (ranges::enable_view): Simplify (LWG 3326). * include/bits/range_access.h (ranges::enable_view): Declare. * include/bits/regex.h (__enable_view_impl): Remove partial specialization. * include/bits/stl_multiset.h (__enable_view_impl): Likewise. * include/bits/stl_set.h (__enable_view_impl): Likewise. * include/bits/unordered_set.h (__enable_view_impl): Likewise. * include/debug/multiset.h (__enable_view_impl): Likewise. * include/debug/set.h (__enable_view_impl): Likewise. * include/debug/unordered_set (__enable_view_impl): Likewise. * include/experimental/string_view (ranges::enable_view): Define partial specialization. * include/std/span (ranges::enable_view): Likewise. * include/std/string_view (ranges::enable_view): Likewise. * testsuite/std/ranges/view.cc: Check satisfaction of updated concept. Tested powerpc64le-linux, committed to master. --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-Transfer-Encoding: quoted-printable Content-length: 12217 commit 3841739c29a54c0141c3156cdd47891c258b2b88 Author: Jonathan Wakely Date: Mon Feb 24 11:45:20 2020 +0000 libstdc++: enable_view has false positives (LWG 3326) =20=20=20=20 * include/std/ranges (__deep_const_range, __enable_view_impl): = Remove. (ranges::enable_view): Simplify (LWG 3326). * include/bits/range_access.h (ranges::enable_view): Declare. * include/bits/regex.h (__enable_view_impl): Remove partial specialization. * include/bits/stl_multiset.h (__enable_view_impl): Likewise. * include/bits/stl_set.h (__enable_view_impl): Likewise. * include/bits/unordered_set.h (__enable_view_impl): Likewise. * include/debug/multiset.h (__enable_view_impl): Likewise. * include/debug/set.h (__enable_view_impl): Likewise. * include/debug/unordered_set (__enable_view_impl): Likewise. * include/experimental/string_view (ranges::enable_view): Define partial specialization. * include/std/span (ranges::enable_view): Likewise. * include/std/string_view (ranges::enable_view): Likewise. * testsuite/std/ranges/view.cc: Check satisfaction of updated c= oncept. diff --git a/libstdc++-v3/include/bits/range_access.h b/libstdc++-v3/includ= e/bits/range_access.h index eb91ade35ff..8b276fd6625 100644 --- a/libstdc++-v3/include/bits/range_access.h +++ b/libstdc++-v3/include/bits/range_access.h @@ -346,6 +346,9 @@ namespace ranges template inline constexpr bool enable_borrowed_range =3D false; =20 + template + extern const bool enable_view; + namespace __detail { template diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/= regex.h index 3307e1c917c..dcae83eea4e 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -2058,16 +2058,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 =20 _GLIBCXX_END_NAMESPACE_CXX11 =20 -#if __cplusplus > 201703L -namespace ranges::__detail -{ - template extern inline const bool __enable_view_impl; - template - inline constexpr bool __enable_view_impl> - =3D false; -} // namespace ranges::__detail -#endif // C++20 - // [28.11.2] Function template regex_match /** * @name Matching, Searching, and Replacing diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/includ= e/bits/stl_multiset.h index b8b82912c91..ab62df1e508 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -1038,17 +1038,6 @@ _GLIBCXX_END_NAMESPACE_CONTAINER _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set) { return __set._M_t; } }; - -#if __cplusplus > 201703L -namespace ranges::__detail -{ - template extern inline const bool __enable_view_impl; - template - inline constexpr bool - __enable_view_impl<_GLIBCXX_STD_C::multiset<_Key, _Compare, _Alloc>> - =3D false; -} // namespace ranges::__detail -#endif // C++20 #endif // C++17 =20 _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bit= s/stl_set.h index 5f3e78dc470..4f8d631bb3b 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -1051,15 +1051,6 @@ _GLIBCXX_END_NAMESPACE_CONTAINER _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set) { return __set._M_t; } }; -#if __cplusplus > 201703L -namespace ranges::__detail -{ - template extern inline const bool __enable_view_impl; - template - inline constexpr bool - __enable_view_impl<_GLIBCXX_STD_C::set<_Key, _Compare, _Alloc>> =3D = false; -} // namespace ranges::__detail -#endif // C++20 #endif // C++17 =20 _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/bits/unordered_set.h b/libstdc++-v3/inclu= de/bits/unordered_set.h index 824eedbae3e..9c2cd45be9c 100644 --- a/libstdc++-v3/include/bits/unordered_set.h +++ b/libstdc++-v3/include/bits/unordered_set.h @@ -1771,21 +1771,6 @@ _GLIBCXX_END_NAMESPACE_CONTAINER _S_get_table(unordered_multiset<_Val, _Hash2, _Eq2, _Alloc>& __set) { return __set._M_h; } }; - -#if __cplusplus > 201703L -namespace ranges::__detail -{ - template extern inline const bool __enable_view_impl; - template - inline constexpr bool - __enable_view_impl<_GLIBCXX_STD_C::unordered_set<_Val, _Hash, _Eq, - _Alloc>> =3D false; - template - inline constexpr bool - __enable_view_impl<_GLIBCXX_STD_C::unordered_multiset<_Val, _Hash, _= Eq, - _Alloc>> =3D false; -} // namespace ranges::__detail -#endif // C++20 #endif // C++17 =20 _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/debug/multiset.h b/libstdc++-v3/include/d= ebug/multiset.h index f5b974ccdc4..fcbba339478 100644 --- a/libstdc++-v3/include/debug/multiset.h +++ b/libstdc++-v3/include/debug/multiset.h @@ -630,19 +630,6 @@ namespace __debug { return __x.swap(__y); } =20 } // namespace __debug - -#if __cplusplus > 201703L -_GLIBCXX_BEGIN_NAMESPACE_VERSION -namespace ranges::__detail -{ - template extern inline const bool __enable_view_impl; - template - inline constexpr bool - __enable_view_impl> - =3D false; -} // namespace ranges::__detail -_GLIBCXX_END_NAMESPACE_VERSION -#endif // C++20 } // namespace std =20 #endif diff --git a/libstdc++-v3/include/debug/set.h b/libstdc++-v3/include/debug/= set.h index f3f90476a48..093ff129f3e 100644 --- a/libstdc++-v3/include/debug/set.h +++ b/libstdc++-v3/include/debug/set.h @@ -641,18 +641,6 @@ namespace __debug { return __x.swap(__y); } =20 } // namespace __debug - -#if __cplusplus > 201703L -_GLIBCXX_BEGIN_NAMESPACE_VERSION -namespace ranges::__detail -{ - template extern inline const bool __enable_view_impl; - template - inline constexpr bool - __enable_view_impl> =3D fa= lse; -} // namespace ranges::__detail -_GLIBCXX_END_NAMESPACE_VERSION -#endif // C++20 } // namespace std =20 #endif diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/includ= e/debug/unordered_set index 040ae7f2ad4..9941bbe1c24 100644 --- a/libstdc++-v3/include/debug/unordered_set +++ b/libstdc++-v3/include/debug/unordered_set @@ -1183,22 +1183,6 @@ namespace __debug { return !(__x =3D=3D __y); } =20 } // namespace __debug -#if __cplusplus > 201703L -_GLIBCXX_BEGIN_NAMESPACE_VERSION -namespace ranges::__detail -{ - template extern inline const bool __enable_view_impl; - template - inline constexpr bool - __enable_view_impl> - =3D false; - template - inline constexpr bool - __enable_view_impl> =3D false; -} // namespace ranges::__detail -_GLIBCXX_END_NAMESPACE_VERSION -#endif // C++20 } // namespace std =20 #endif // C++11 diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/i= nclude/experimental/string_view index 439650154ae..629db577c29 100644 --- a/libstdc++-v3/include/experimental/string_view +++ b/libstdc++-v3/include/experimental/string_view @@ -694,12 +694,16 @@ namespace experimental #if __cpp_lib_concepts namespace ranges { - template extern inline const bool enable_borrowed_range; // Opt-in to borrowed_range concept template inline constexpr bool enable_borrowed_range> =3D true; + + // Opt-in to view concept + template + inline constexpr bool + enable_view> =3D true; } #endif =20 diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ran= ges index 8c925fa278b..0b2057c9661 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -65,25 +65,8 @@ namespace ranges =20 struct view_base { }; =20 - namespace __detail - { - template - concept __deep_const_range =3D range<_Tp> && range - && same_as, range_reference_t>; - - template - inline constexpr bool __enable_view_impl - =3D derived_from<_Tp, view_base> || (!__deep_const_range<_Tp>); - - template - inline constexpr bool __enable_view_impl> - =3D false; - - } // namespace __detail - template - inline constexpr bool enable_view - =3D __detail::__enable_view_impl>; + inline constexpr bool enable_view =3D derived_from<_Tp, view_base>; =20 template concept view diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span index 16b09a1e50c..f658adb04cf 100644 --- a/libstdc++-v3/include/std/span +++ b/libstdc++-v3/include/std/span @@ -447,11 +447,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION =20 namespace ranges { - template extern inline const bool enable_borrowed_range; // Opt-in to borrowed_range concept template inline constexpr bool enable_borrowed_range> =3D true; + + // Opt-in to view concept + template + inline constexpr bool + enable_view> + =3D _Extent =3D=3D 0 || _Extent =3D=3D dynamic_extent; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace std diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/st= d/string_view index 16687f6c352..ea5d547e006 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -727,11 +727,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cpp_lib_concepts namespace ranges { - template extern inline const bool enable_borrowed_range; // Opt-in to borrowed_range concept template inline constexpr bool enable_borrowed_range> =3D true; + + // Opt-in to view concept + template + inline constexpr bool + enable_view> =3D true; } #endif _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/testsuite/std/ranges/view.cc b/libstdc++-v3/tests= uite/std/ranges/view.cc index d76c8013c2c..72e8bcb50d7 100644 --- a/libstdc++-v3/testsuite/std/ranges/view.cc +++ b/libstdc++-v3/testsuite/std/ranges/view.cc @@ -19,13 +19,23 @@ // { dg-do compile { target c++2a } } =20 #include +#include +#include +#include +#include #include #include #include #include #include =20 -static_assert(std::ranges::view>); +static_assert(std::ranges::view>); +static_assert(std::ranges::view>); +static_assert(!std::ranges::view>); +static_assert(std::ranges::view); +static_assert(std::ranges::view); + +static_assert(!std::ranges::view>); static_assert(!std::ranges::view>); static_assert(!std::ranges::view>); static_assert(!std::ranges::view>); --gKMricLos+KVdGMg--