From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28720 invoked by alias); 26 Jun 2014 10:33:57 -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 28689 invoked by uid 89); 26 Jun 2014 10:33:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 26 Jun 2014 10:33:56 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5QAXsX2026179 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Jun 2014 06:33:54 -0400 Received: from localhost (vpn1-4-174.ams2.redhat.com [10.36.4.174]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5QAXrBF014058; Thu, 26 Jun 2014 06:33:54 -0400 Date: Thu, 26 Jun 2014 10:33:00 -0000 From: Jonathan Wakely To: =?iso-8859-1?Q?Fran=E7ois?= Dumont Cc: "libstdc++@gcc.gnu.org" , gcc-patches Subject: Re: testsuite allocators patch Message-ID: <20140626103353.GA1725@redhat.com> References: <53A49B7C.5080506@gmail.com> <53AB276F.10806@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <53AB276F.10806@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2014-06/txt/msg02113.txt.bz2 On 25/06/14 21:47 +0200, François Dumont wrote: >> I would like to finally propose this patch before the one on >>_Rb_tree, as a separate one. >> >> I have adopted the same evolution on the tracker_allocator with >>even a perfect forwarding constructor to allow its usage on top of >>the uneq_allocator which take a personality parameter. Doing so I >>realized that move_assign_neg.cc tests were not accurate enough as >>they needed a non move propagating allocator and the uneq_allocator >>were not explicitly non propagating. Ah, that's good to improve them then. >Index: testsuite/util/testsuite_allocator.h >=================================================================== >--- testsuite/util/testsuite_allocator.h (revision 211713) >+++ testsuite/util/testsuite_allocator.h (working copy) >@@ -87,103 +81,142 @@ > static int destructCount_; > }; > >- // A simple basic allocator that just forwards to the >+ // Helper to detect inconsistency between type used to instantiate an >+ // allocator and the underlying allocator value_type. >+ template+ typename = typename Alloc::value_type> >+ struct check_consistent_alloc_value_type; >+ >+ template >+ struct check_consistent_alloc_value_type >+ { typedef T value_type; }; >+ >+ // An allocator facade that just intercepts some calls and forward them to the > // tracker_allocator_counter to fulfill memory requests. This class This comment is no longer true, tracker_allocator_counter does not fulfil the memory requests. > // is templated on the target object type, but tracker isn't. >- template >- class tracker_allocator >- { >- private: >- typedef tracker_allocator_counter counter_type; >+ template > >+ class tracker_allocator : public Alloc >+ { >+ private: >+ typedef tracker_allocator_counter counter_type; > >- public: >- typedef T value_type; >- typedef T* pointer; >- typedef const T* const_pointer; >- typedef T& reference; >- typedef const T& const_reference; >- typedef std::size_t size_type; >- typedef std::ptrdiff_t difference_type; >+ typedef __gnu_cxx::__alloc_traits AllocTraits; >+ >+ public: >+ typedef typename >+ check_consistent_alloc_value_type::value_type value_type; >+ typedef typename AllocTraits::pointer pointer; >+ typedef typename AllocTraits::size_type size_type; Thanks for doing this - I think it makes the facade more useful if it uses allocator_traits and so can be combined with SimpleAllocator and CustomPointerAlloc. >- template struct rebind { typedef tracker_allocator other; }; >+ template >+ struct rebind >+ { >+ typedef tracker_allocator+ typename AllocTraits::template rebind::other> other; >+ }; > >- pointer >- address(reference value) const _GLIBCXX_NOEXCEPT >- { return std::__addressof(value); } >+#if __cplusplus >= 201103L >+ tracker_allocator() = default; >+ tracker_allocator(const tracker_allocator&) = default; >+ tracker_allocator(tracker_allocator&&) = default; > >- const_pointer >- address(const_reference value) const _GLIBCXX_NOEXCEPT >- { return std::__addressof(value); } >+ // Perfect forwarding constructor. >+ template >+ tracker_allocator(_Args&&... __args) >+ : Alloc(std::forward<_Args>(__args)...) >+ { } >+#else >+ tracker_allocator() _GLIBCXX_USE_NOEXCEPT The _GLIBCXX_USE_NOEXCEPT macro expands to nothing in C++03 mode, so you might as well omit it in the #else branch. OK for trunk if you make the tracker_allocator comment correct. Thanks!