From patchwork Tue Oct 18 18:41:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 78117 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1025192qge; Tue, 18 Oct 2016 11:41:34 -0700 (PDT) X-Received: by 10.98.138.79 with SMTP id y76mr3215277pfd.158.1476816094413; Tue, 18 Oct 2016 11:41:34 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ws4si30823089pab.149.2016.10.18.11.41.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Oct 2016 11:41:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-438954-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-438954-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-438954-patch=linaro.org@gcc.gnu.org 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:references:mime-version:content-type :content-transfer-encoding:in-reply-to; q=dns; s=default; b=r40o oJiWB3DPdZDTnJ2xpbWpu1Na3e6Dcp/6nzc1Ax771IWKkzP2fv8aod20xCvnshLG q5d15QHbCYe0dwfSVmEVsXztB9KyKh2blcBT0+QpW5VZTJr06jUPhRLt7SqEHcWA usKosKtxIyWHluxuJ2KIVQpMXNpZtdiBR3wCp+o= 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:references:mime-version:content-type :content-transfer-encoding:in-reply-to; s=default; bh=2borhb2211 wkEwG/AsDlh9q9rkc=; b=dcycKavTnfSxGUqjoTr6CuBNW6R2AQW0Mubvcjym1N ERMbt7qqm6VZcU0u/0iITuhUY8ovmsuANS4Tro7pgYSuAyDHJ+9vsS0SWQo7QkeM szPFr0SYWw8k7wmjUeCKaduj+ASZy2CnvrOV2I0N6wHiwqLUpzOSATJ0BLXG5JKl Y= Received: (qmail 119755 invoked by alias); 18 Oct 2016 18:41:19 -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 119723 invoked by uid 89); 18 Oct 2016 18:41:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=BAYES_20, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=_tp1, shared_ptr.h, shared_ptrh, __r X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Oct 2016 18:41:15 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F1288553F; Tue, 18 Oct 2016 18:41:14 +0000 (UTC) Received: from localhost (ovpn-116-70.ams2.redhat.com [10.36.116.70]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9IIfDSx017459; Tue, 18 Oct 2016 14:41:13 -0400 Date: Tue, 18 Oct 2016 19:41:12 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix typos in experimental::shared_ptr Message-ID: <20161018184112.GU2922@redhat.com> References: <20161018183027.GA3716@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161018183027.GA3716@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.7.0 (2016-08-17) On 18/10/16 19:30 +0100, Jonathan Wakely wrote: >A couple of minor things I found whlie reviewing this code. > > * include/experimental/bits/shared_ptr.h (shared_ptr(shared_ptr&&)): > Remove const from parameter. > (operator<(const shared_ptr&, nullptr_t)): Use correct > specialization of std::less. > * testsuite/experimental/memory/shared_ptr/comparison/comparison.cc: > Test comparison with nullptr and actually call test functions. > >Tested x86_64-linux, comitted to trunk. I'm also committing this, which only changes whitespace. commit f9faa4b10d1039df4dd8837149703eac1866c923 Author: Jonathan Wakely Date: Tue Oct 18 19:39:11 2016 +0100 Fix indentation of experimental::shared_ptr code * include/experimental/bits/shared_ptr.h: Fix indentation. diff --git a/libstdc++-v3/include/experimental/bits/shared_ptr.h b/libstdc++-v3/include/experimental/bits/shared_ptr.h index 7a232f4..e0ec00c 100644 --- a/libstdc++-v3/include/experimental/bits/shared_ptr.h +++ b/libstdc++-v3/include/experimental/bits/shared_ptr.h @@ -768,170 +768,170 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; // C++14 ??20.8.2.2.7 //DOING - template - bool operator==(const shared_ptr<_Tp1>& __a, - const shared_ptr<_Tp2>& __b) noexcept - { return __a.get() == __b.get(); } + template + bool operator==(const shared_ptr<_Tp1>& __a, + const shared_ptr<_Tp2>& __b) noexcept + { return __a.get() == __b.get(); } - template - inline bool - operator==(const shared_ptr<_Tp>& __a, nullptr_t) noexcept - { return !__a; } + template + inline bool + operator==(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return !__a; } - template - inline bool - operator==(nullptr_t, const shared_ptr<_Tp>& __a) noexcept - { return !__a; } + template + inline bool + operator==(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return !__a; } - template - inline bool - operator!=(const shared_ptr<_Tp1>& __a, - const shared_ptr<_Tp2>& __b) noexcept - { return __a.get() != __b.get(); } - - template - inline bool - operator!=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept - { return (bool)__a; } - - template - inline bool - operator!=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept - { return (bool)__a; } - - template - inline bool - operator<(const shared_ptr<_Tp1>& __a, + template + inline bool + operator!=(const shared_ptr<_Tp1>& __a, const shared_ptr<_Tp2>& __b) noexcept - { - using __elem_t1 = typename shared_ptr<_Tp1>::element_type; - using __elem_t2 = typename shared_ptr<_Tp2>::element_type; - using _CT = common_type_t<__elem_t1*, __elem_t2*>; - return std::less<_CT>()(__a.get(), __b.get()); - } + { return __a.get() != __b.get(); } - template - inline bool - operator<(const shared_ptr<_Tp>& __a, nullptr_t) noexcept - { - using __elem_t = typename shared_ptr<_Tp>::element_type; - return std::less<__elem_t*>()(__a.get(), nullptr); - } + template + inline bool + operator!=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return (bool)__a; } - template - inline bool - operator<(nullptr_t, const shared_ptr<_Tp>& __a) noexcept - { - using __elem_t = typename shared_ptr<_Tp>::element_type; - return std::less<__elem_t*>()(nullptr, __a.get()); - } + template + inline bool + operator!=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return (bool)__a; } - template - inline bool - operator<=(const shared_ptr<_Tp1>& __a, - const shared_ptr<_Tp2>& __b) noexcept - { return !(__b < __a); } + template + inline bool + operator<(const shared_ptr<_Tp1>& __a, + const shared_ptr<_Tp2>& __b) noexcept + { + using __elem_t1 = typename shared_ptr<_Tp1>::element_type; + using __elem_t2 = typename shared_ptr<_Tp2>::element_type; + using _CT = common_type_t<__elem_t1*, __elem_t2*>; + return std::less<_CT>()(__a.get(), __b.get()); + } - template - inline bool - operator<=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept - { return !(nullptr < __a); } + template + inline bool + operator<(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { + using __elem_t = typename shared_ptr<_Tp>::element_type; + return std::less<__elem_t*>()(__a.get(), nullptr); + } - template - inline bool - operator<=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept - { return !(__a < nullptr); } + template + inline bool + operator<(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { + using __elem_t = typename shared_ptr<_Tp>::element_type; + return std::less<__elem_t*>()(nullptr, __a.get()); + } - template - inline bool - operator>(const shared_ptr<_Tp1>& __a, + template + inline bool + operator<=(const shared_ptr<_Tp1>& __a, const shared_ptr<_Tp2>& __b) noexcept - { return (__b < __a); } + { return !(__b < __a); } - template - inline bool - operator>(const shared_ptr<_Tp>& __a, nullptr_t) noexcept - { - using __elem_t = typename shared_ptr<_Tp>::element_type; - return std::less<__elem_t*>()(nullptr, __a.get()); - } + template + inline bool + operator<=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return !(nullptr < __a); } - template - inline bool - operator>(nullptr_t, const shared_ptr<_Tp>& __a) noexcept - { - using __elem_t = typename shared_ptr<_Tp>::element_type; - return std::less<__elem_t*>()(__a.get(), nullptr); - } + template + inline bool + operator<=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return !(__a < nullptr); } - template - inline bool - operator>=(const shared_ptr<_Tp1>& __a, - const shared_ptr<_Tp2>& __b) noexcept - { return !(__a < __b); } + template + inline bool + operator>(const shared_ptr<_Tp1>& __a, + const shared_ptr<_Tp2>& __b) noexcept + { return (__b < __a); } - template - inline bool - operator>=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept - { return !(__a < nullptr); } + template + inline bool + operator>(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { + using __elem_t = typename shared_ptr<_Tp>::element_type; + return std::less<__elem_t*>()(nullptr, __a.get()); + } - template - inline bool - operator>=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept - { return !(nullptr < __a); } + template + inline bool + operator>(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { + using __elem_t = typename shared_ptr<_Tp>::element_type; + return std::less<__elem_t*>()(__a.get(), nullptr); + } - // C++14 ??20.8.2.2.8 - template - inline void - swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept - { __a.swap(__b); } + template + inline bool + operator>=(const shared_ptr<_Tp1>& __a, + const shared_ptr<_Tp2>& __b) noexcept + { return !(__a < __b); } - // 8.2.1.3, shared_ptr casts - template - inline shared_ptr<_Tp> - static_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept - { - using __elem_t = typename shared_ptr<_Tp>::element_type; - return shared_ptr<_Tp>(__r, static_cast<__elem_t*>(__r.get())); - } + template + inline bool + operator>=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return !(__a < nullptr); } - template - inline shared_ptr<_Tp> - dynamic_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept - { - using __elem_t = typename shared_ptr<_Tp>::element_type; - if (_Tp* __p = dynamic_cast<__elem_t*>(__r.get())) - return shared_ptr<_Tp>(__r, __p); - return shared_ptr<_Tp>(); - } + template + inline bool + operator>=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return !(nullptr < __a); } - template - inline shared_ptr<_Tp> - const_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept - { - using __elem_t = typename shared_ptr<_Tp>::element_type; - return shared_ptr<_Tp>(__r, const_cast<__elem_t*>(__r.get())); - } + // C++14 ??20.8.2.2.8 + template + inline void + swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept + { __a.swap(__b); } - template - inline shared_ptr<_Tp> - reinterpret_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept - { - using __elem_t = typename shared_ptr<_Tp>::element_type; - return shared_ptr<_Tp>(__r, reinterpret_cast<__elem_t*>(__r.get())); - } + // 8.2.1.3, shared_ptr casts + template + inline shared_ptr<_Tp> + static_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept + { + using __elem_t = typename shared_ptr<_Tp>::element_type; + return shared_ptr<_Tp>(__r, static_cast<__elem_t*>(__r.get())); + } - // C++14 ??20.8.2.3 - template - class weak_ptr : public __weak_ptr<_Tp> - { + template + inline shared_ptr<_Tp> + dynamic_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept + { + using __elem_t = typename shared_ptr<_Tp>::element_type; + if (_Tp* __p = dynamic_cast<__elem_t*>(__r.get())) + return shared_ptr<_Tp>(__r, __p); + return shared_ptr<_Tp>(); + } + + template + inline shared_ptr<_Tp> + const_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept + { + using __elem_t = typename shared_ptr<_Tp>::element_type; + return shared_ptr<_Tp>(__r, const_cast<__elem_t*>(__r.get())); + } + + template + inline shared_ptr<_Tp> + reinterpret_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept + { + using __elem_t = typename shared_ptr<_Tp>::element_type; + return shared_ptr<_Tp>(__r, reinterpret_cast<__elem_t*>(__r.get())); + } + + // C++14 ??20.8.2.3 + template + class weak_ptr : public __weak_ptr<_Tp> + { template using _Compatible = enable_if_t<__sp_compatible<_Tp1, _Tp>::value, _Res>; using _Base_type = __weak_ptr<_Tp>; - public: + public: constexpr weak_ptr() noexcept = default; template> @@ -985,13 +985,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return shared_ptr<_Tp>(*this, std::nothrow); } friend class enable_shared_from_this<_Tp>; - }; + }; - // C++14 ??20.8.2.3.6 - template - inline void - swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b) noexcept - { __a.swap(__b); } + // C++14 ??20.8.2.3.6 + template + inline void + swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b) noexcept + { __a.swap(__b); } /// C++14 ??20.8.2.2.10 template @@ -1009,8 +1009,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __os; } - // C++14 ??20.8.2.4 - template class owner_less; + // C++14 ??20.8.2.4 + template class owner_less; /// Partial specialization of owner_less for shared_ptr. template