From patchwork Fri Jan 24 17:21:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1228962 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518235-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=gkfHsaLG; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=c8etB6oK; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4845Y10fw7z9sR1 for ; Sat, 25 Jan 2020 04:21:54 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=UJrk1Wn2eebHB5Nn4AUvXmjEfQpunV9Cxl3jD+MDRnviCEwLpcxOS u8KEuU24YcEEf7RgG3QXiT+MBaMp6bHun+yAv6ttmPQSYUovhB/OLDshya0G+mHI LOW7raG61B7B2dj/so7PzZYLoMXn6GKx1RXb097aLv+iTAN2To6Aw0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=Pq4KsIGUcI/Wst99vo8p3DUG7gc=; b=gkfHsaLGXNMw+BDIMJmR mTGCwZnKun9hglmSCPHIsLbrGZkhGQkJ+nH9DCYirJbaSJeJB9e2AuUMLgJdTn/t ahOdEUqyPphOIn1aQfYdnWIzeHsBddLCc9+hcQum24aw26pwFIqZzOCLiYa1fnPO iTgIvvUIBVwQPw7LQ57baNc= Received: (qmail 28404 invoked by alias); 24 Jan 2020 17:21:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 28395 invoked by uid 89); 24 Jan 2020 17:21:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.8 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=HX-Languages-Length:4619 X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Jan 2020 17:21:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579886503; 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=+pzAthaQxkqZKlOEeWeyZKh40SE/JT6lnRkxH8lxKDE=; b=c8etB6oKj04sX/4Gd2jv2aOpHRQpgdcZl8OQ7YvpM02qp8T6OH0ZvpfnfHyO6St6NKhFgk wbuef+idshCgLlbSuYlM3GiIlcW+nKPZ3gKng2kp7HHgwOiRbWd1+hg9zpOUkoA73fj7r9 j5WShBsqbXIYMYIhmuTVmhgd+/SQ/XM= 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-426-lGocu_Y8OtKrxln_yJ9lfg-1; Fri, 24 Jan 2020 12:21:39 -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 B32EF100551B; Fri, 24 Jan 2020 17:21:38 +0000 (UTC) Received: from localhost (unknown [10.33.36.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F2161001B03; Fri, 24 Jan 2020 17:21:38 +0000 (UTC) Date: Fri, 24 Jan 2020 17:21:37 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [COMMITTED] libstdc++: Simplify construction of comparison category types Message-ID: <20200124172137.GA388198@redhat.com> MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline The _Eq and _Ord enumerations can be combined into one, reducing the number of constructors needed for the comparison category types. The redundant equal enumerator can be removed and equivalent used in its place. The _Less and _Greater enumerators can be renamed because 'less' and 'greater' are already reserved names anyway. * libsupc++/compare (__cmp_cat::_Eq): Remove enumeration type. (__cmp_cat::_Ord::equivalent): Add enumerator. (__cmp_cat::_Ord::_Less, __cmp_cat::_Ord::_Greater): Rename to less and greater. (partial_ordering, weak_ordering, strong_ordering): Remove constructors taking __cmp_cat::_Eq parameters. Use renamed enumerators. Tested powerpc64le-linux, committed to trunk. commit 482eeff5f114c7635c1a06edb2deee3e5433c3f3 Author: Jonathan Wakely Date: Fri Jan 24 17:07:01 2020 +0000 libstdc++: Simplify construction of comparison category types The _Eq and _Ord enumerations can be combined into one, reducing the number of constructors needed for the comparison category types. The redundant equal enumerator can be removed and equivalent used in its place. The _Less and _Greater enumerators can be renamed because 'less' and 'greater' are already reserved names anyway. * libsupc++/compare (__cmp_cat::_Eq): Remove enumeration type. (__cmp_cat::_Ord::equivalent): Add enumerator. (__cmp_cat::_Ord::_Less, __cmp_cat::_Ord::_Greater): Rename to less and greater. (partial_ordering, weak_ordering, strong_ordering): Remove constructors taking __cmp_cat::_Eq parameters. Use renamed enumerators. diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare index 98a592cbb14..117340ff184 100644 --- a/libstdc++-v3/libsupc++/compare +++ b/libstdc++-v3/libsupc++/compare @@ -48,10 +48,7 @@ namespace std namespace __cmp_cat { - enum class _Eq - { equal = 0, equivalent = equal, nonequal = 1, nonequivalent = nonequal }; - - enum class _Ord { _Less = -1, _Greater = 1 }; + enum class _Ord { equivalent = 0, less = -1, greater = 1 }; enum class _Ncmp { _Unordered = -127 }; @@ -66,11 +63,6 @@ namespace std int _M_value; bool _M_is_ordered; - constexpr explicit - partial_ordering(__cmp_cat::_Eq __v) noexcept - : _M_value(int(__v)), _M_is_ordered(true) - { } - constexpr explicit partial_ordering(__cmp_cat::_Ord __v) noexcept : _M_value(int(__v)), _M_is_ordered(true) @@ -146,13 +138,13 @@ namespace std // valid values' definitions inline constexpr partial_ordering - partial_ordering::less(__cmp_cat::_Ord::_Less); + partial_ordering::less(__cmp_cat::_Ord::less); inline constexpr partial_ordering - partial_ordering::equivalent(__cmp_cat::_Eq::equivalent); + partial_ordering::equivalent(__cmp_cat::_Ord::equivalent); inline constexpr partial_ordering - partial_ordering::greater(__cmp_cat::_Ord::_Greater); + partial_ordering::greater(__cmp_cat::_Ord::greater); inline constexpr partial_ordering partial_ordering::unordered(__cmp_cat::_Ncmp::_Unordered); @@ -161,10 +153,6 @@ namespace std { int _M_value; - constexpr explicit - weak_ordering(__cmp_cat::_Eq __v) noexcept : _M_value(int(__v)) - { } - constexpr explicit weak_ordering(__cmp_cat::_Ord __v) noexcept : _M_value(int(__v)) { } @@ -243,23 +231,18 @@ namespace std // valid values' definitions inline constexpr weak_ordering - weak_ordering::less(__cmp_cat::_Ord::_Less); + weak_ordering::less(__cmp_cat::_Ord::less); inline constexpr weak_ordering - weak_ordering::equivalent(__cmp_cat::_Eq::equivalent); + weak_ordering::equivalent(__cmp_cat::_Ord::equivalent); inline constexpr weak_ordering - weak_ordering::greater(__cmp_cat::_Ord::_Greater); + weak_ordering::greater(__cmp_cat::_Ord::greater); class strong_ordering { int _M_value; - constexpr explicit - strong_ordering(__cmp_cat::_Eq __v) noexcept - : _M_value(int(__v)) - { } - constexpr explicit strong_ordering(__cmp_cat::_Ord __v) noexcept : _M_value(int(__v)) @@ -350,16 +333,16 @@ namespace std // valid values' definitions inline constexpr strong_ordering - strong_ordering::less(__cmp_cat::_Ord::_Less); + strong_ordering::less(__cmp_cat::_Ord::less); inline constexpr strong_ordering - strong_ordering::equal(__cmp_cat::_Eq::equal); + strong_ordering::equal(__cmp_cat::_Ord::equivalent); inline constexpr strong_ordering - strong_ordering::equivalent(__cmp_cat::_Eq::equivalent); + strong_ordering::equivalent(__cmp_cat::_Ord::equivalent); inline constexpr strong_ordering - strong_ordering::greater(__cmp_cat::_Ord::_Greater); + strong_ordering::greater(__cmp_cat::_Ord::greater); // named comparison functions