From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17062 invoked by alias); 19 Feb 2020 10:57:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 17052 invoked by uid 89); 19 Feb 2020 10:57:24 -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,SPF_PASS 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; Wed, 19 Feb 2020 10:57:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582109841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=m3W1Btf+fz9Zx9tyBWzdKXtR0PEOVcrvw0uAaexmbbw=; b=TAh9j1m/lY/lwHTSZAc08YKN6pAlzIFaoINcylQls3FX6GBQQw7rIIAkAf1HNI4JrGVwY5 c3jcaiP1dSjHy7eig61cgbNN9tVvCOk+oZAihDwnbh9RqlFQ2FqdRKrmqgtaTlLY1uUnIL mHx0gGaCIQLWXsXz/xfgHAT4nR/iVR4= 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-99-XSeT-EPTMwahKDdXW1Nseg-1; Wed, 19 Feb 2020 05:57:18 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A64D21088390; Wed, 19 Feb 2020 10:57:17 +0000 (UTC) Received: from localhost (unknown [10.33.36.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B17C10027A8; Wed, 19 Feb 2020 10:57:17 +0000 (UTC) Date: Wed, 19 Feb 2020 10:57:00 -0000 From: Jonathan Wakely To: Tim Song Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, ppalka@redhat.com Subject: Re: [committed] libstdc++: P1964R2 Wording for boolean-testable Message-ID: <20200219105716.GL9441@redhat.com> References: <20200217183352.GA1574923@redhat.com> <20200218134905.GA9441@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200218134905.GA9441@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="t5NgoZwlhlUmGr82" Content-Disposition: inline X-SW-Source: 2020-02/txt/msg01091.txt.bz2 --t5NgoZwlhlUmGr82 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 699 On 18/02/20 13:49 +0000, Jonathan Wakely wrote: >On 17/02/20 22:27 +0100, Tim Song wrote: >>On Mon, Feb 17, 2020 at 12:34 PM Jonathan Wakely wro= te: >> >>>This removes the complicated std::boolean concept, as agreed in Prague. >>> >>> * include/bits/ranges_algo.h (__find_fn, __find_first_of_fn) >>> (__adjacent_find_fn): Cast result of predicate to bool. >> >> >> >>Um, why? These look fine without the cast. (The WP was doing =3D=3D false, >>which is a different matter.) > >Good point, I'll undo those bits. Thanks. Looks like we have a few other casts to bool that are redundant post-p1946r2, not just the ones I added. This removes them, testing it now. --t5NgoZwlhlUmGr82 Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-Transfer-Encoding: quoted-printable Content-length: 4010 commit a51a8daabd0ae08e2ee33bbc3c5a52cb20ac0eef Author: Jonathan Wakely Date: Wed Feb 19 10:40:24 2020 +0000 libstdc++: Remove redundant bool casts in ranges algorithms =20=20=20=20 Some of these casts were added by me the other day, but some were already present. I think they are all redundant following the introduction of the boolean-testable concept in P1964R2. =20=20=20=20 * include/bits/ranges_algo.h (__find_fn, __find_first_of_fn) (__adjacent_find_fn, __remove_if_fn, __remove_copy_if_fn) (__unique_fn, __unique_copy_fn): Remove redundant conversions t= o bool. diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include= /bits/ranges_algo.h index 31b1bf0d448..a69181e12cb 100644 --- a/libstdc++-v3/include/bits/ranges_algo.h +++ b/libstdc++-v3/include/bits/ranges_algo.h @@ -244,7 +244,7 @@ namespace ranges const _Tp& __value, _Proj __proj =3D {}) const { while (__first !=3D __last - && !(bool)(std::__invoke(__proj, *__first) =3D=3D __value)) + && !(std::__invoke(__proj, *__first) =3D=3D __value)) ++__first; return __first; } @@ -333,9 +333,9 @@ namespace ranges { for (; __first1 !=3D __last1; ++__first1) for (auto __iter =3D __first2; __iter !=3D __last2; ++__iter) - if ((bool)std::__invoke(__pred, - std::__invoke(__proj1, *__first1), - std::__invoke(__proj2, *__iter))) + if (std::__invoke(__pred, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__iter))) return __first1; return __first1; } @@ -730,9 +730,9 @@ namespace ranges auto __next =3D __first; for (; ++__next !=3D __last; __first =3D __next) { - if ((bool)std::__invoke(__pred, - std::__invoke(__proj, *__first), - std::__invoke(__proj, *__next))) + if (std::__invoke(__pred, + std::__invoke(__proj, *__first), + std::__invoke(__proj, *__next))) return __first; } return __next; @@ -1219,7 +1219,7 @@ namespace ranges auto __result =3D __first; ++__first; for (; __first !=3D __last; ++__first) - if (!(bool)std::__invoke(__pred, std::__invoke(__proj, *__first))) + if (!std::__invoke(__pred, std::__invoke(__proj, *__first))) { *__result =3D std::move(*__first); ++__result; @@ -1289,7 +1289,7 @@ namespace ranges _Pred __pred, _Proj __proj =3D {}) const { for (; __first !=3D __last; ++__first) - if (!(bool)std::__invoke(__pred, std::__invoke(__proj, *__first))) + if (!std::__invoke(__pred, std::__invoke(__proj, *__first))) { *__result =3D *__first; ++__result; @@ -1372,9 +1372,9 @@ namespace ranges auto __dest =3D __first; ++__first; while (++__first !=3D __last) - if (!(bool)std::__invoke(__comp, - std::__invoke(__proj, *__dest), - std::__invoke(__proj, *__first))) + if (!std::__invoke(__comp, + std::__invoke(__proj, *__dest), + std::__invoke(__proj, *__first))) *++__dest =3D std::move(*__first); return {++__dest, __first}; } @@ -1420,9 +1420,9 @@ namespace ranges auto __next =3D __first; *__result =3D *__next; while (++__next !=3D __last) - if (!(bool)std::__invoke(__comp, - std::__invoke(__proj, *__first), - std::__invoke(__proj, *__next))) + if (!std::__invoke(__comp, + std::__invoke(__proj, *__first), + std::__invoke(__proj, *__next))) { __first =3D __next; *++__result =3D *__first; @@ -1434,9 +1434,9 @@ namespace ranges { *__result =3D *__first; while (++__first !=3D __last) - if (!(bool)std::__invoke(__comp, - std::__invoke(__proj, *__result), - std::__invoke(__proj, *__first))) + if (!std::__invoke(__comp, + std::__invoke(__proj, *__result), + std::__invoke(__proj, *__first))) *++__result =3D *__first; return {std::move(__first), std::move(++__result)}; } --t5NgoZwlhlUmGr82--