From patchwork Sun Jun 5 20:38:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 98778 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 38ABFB6F93 for ; Mon, 6 Jun 2011 06:39:15 +1000 (EST) Received: (qmail 23682 invoked by alias); 5 Jun 2011 20:39:13 -0000 Received: (qmail 23666 invoked by uid 22791); 5 Jun 2011 20:39:12 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RFC_ABUSE_POST, TW_CX X-Spam-Check-By: sourceware.org Received: from mail-pw0-f47.google.com (HELO mail-pw0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 05 Jun 2011 20:38:58 +0000 Received: by pwj9 with SMTP id 9so1852411pwj.20 for ; Sun, 05 Jun 2011 13:38:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.62.35 with SMTP id k35mr629659wfa.67.1307306337965; Sun, 05 Jun 2011 13:38:57 -0700 (PDT) Received: by 10.142.106.17 with HTTP; Sun, 5 Jun 2011 13:38:57 -0700 (PDT) Date: Sun, 5 Jun 2011 21:38:57 +0100 Message-ID: Subject: [v3] fix typos in ptr_traits.h and specialize for pointer adapter From: Jonathan Wakely To: "libstdc++" , gcc-patches 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 2011-06-05 Jonathan Wakely * include/bits/ptr_traits.h (pointer_traits): Fix typos. * include/ext/pointer.h (pointer_traits): Add partial specialization for _Pointer_adapter. This fixes a couple of dumb mistakes in pointer_traits (type vs __type and not actually declaring friends as friends) and adds a specialization for __gnu_cxx::_Pointer_adapter, which is needed because the default specialization gives the wrong result for pointer_traits::rebind, preventing _Pointer_adapter from being used by containers using the full C++0x allocator API (which I'm currently working on.) Tested x86_64-linux and committed to trunk. Index: include/bits/ptr_traits.h =================================================================== --- include/bits/ptr_traits.h (revision 174624) +++ include/bits/ptr_traits.h (working copy) @@ -106,8 +106,8 @@ _GLIBCXX_HAS_NESTED_TYPE(difference_type /* TODO: remove second bool when alias templates are supported */ template::value, - bool = __ptrtr_rebind_helper2<_Tp, _Up>::value> + bool = __ptrtr_rebind_helper<_Tp, _Up>::__value, + bool = __ptrtr_rebind_helper2<_Tp, _Up>::__value> struct __ptrtr_rebind; template @@ -178,8 +178,9 @@ _GLIBCXX_HAS_NESTED_TYPE(difference_type { typedef typename __ptrtr_rebind<_Ptr, _Up>::__type __type; }; // allocator_traits needs to use __rebind - template struct allocator_traits; - template class __ptrtr_rebind_helper2; + template friend struct allocator_traits; + template friend struct pointer_traits; + template friend class __ptrtr_rebind_helper2; }; /** Index: include/ext/pointer.h =================================================================== --- include/ext/pointer.h (revision 174624) +++ include/ext/pointer.h (working copy) @@ -42,6 +42,9 @@ #include #include #include +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# include +#endif namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { @@ -567,4 +570,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } // namespace +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + struct pointer_traits<__gnu_cxx::_Pointer_adapter<_Storage_policy>> + { + /// The pointer type + typedef __gnu_cxx::_Pointer_adapter<_Storage_policy> pointer; + /// The type pointed to + typedef typename pointer::element_type element_type; + /// Type used to represent the difference between two pointers + typedef typename pointer::difference_type difference_type; + + /* TODO: replace __rebind with alias template rebind */ + /* + template + using rebind<_Up> = typename __gnu_cxx::_Pointer_adapter< + typename pointer_traits<_Storage_policy>::rebind<_Up>> + */ + template + class __rebind + { + typedef pointer_traits<_Storage_policy> _Policy_traits; + typedef typename _Policy_traits::template __rebind<_Up>::__type + _Rebound_policy; + public: + typedef typename __gnu_cxx::_Pointer_adapter<_Rebound_policy> __type; + }; + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif + #endif // _POINTER_H