From 7579d15b5819a8df09e1ba4ae05d765185b6bba8 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 8 Nov 2011 00:33:45 +0000 Subject: [PATCH] ptr_traits.h (__rebind): Replace with... * include/bits/ptr_traits.h (__rebind): Replace with... (rebind): Implement using alias-declaration. * include/ext/pointer.h (__rebind): Replace with... (rebind): Implement using alias-declaration. * include/bits/alloc_traits.h (__rebind_alloc, __rebind_traits): Replace with... (rebind_alloc, rebind_traits): Implement using alias-declaration. * include/ext/alloc_traits.h (rebind): Use rebind_alloc instead of __rebind_alloc. * include/std/scoped_allocator (rebind): Likewise. From-SVN: r181139 --- libstdc++-v3/ChangeLog | 13 ++++++ libstdc++-v3/include/bits/alloc_traits.h | 23 ++--------- libstdc++-v3/include/bits/ptr_traits.h | 50 +++-------------------- libstdc++-v3/include/ext/alloc_traits.h | 2 +- libstdc++-v3/include/ext/pointer.h | 14 +------ libstdc++-v3/include/std/scoped_allocator | 3 +- 6 files changed, 26 insertions(+), 79 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1583ef0aadf..5f4160640e3 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,16 @@ +2011-11-08 Jonathan Wakely + + * include/bits/ptr_traits.h (__rebind): Replace with... + (rebind): Implement using alias-declaration. + * include/ext/pointer.h (__rebind): Replace with... + (rebind): Implement using alias-declaration. + * include/bits/alloc_traits.h (__rebind_alloc, __rebind_traits): + Replace with... + (rebind_alloc, rebind_traits): Implement using alias-declaration. + * include/ext/alloc_traits.h (rebind): Use rebind_alloc instead of + __rebind_alloc. + * include/std/scoped_allocator (rebind): Likewise. + 2011-11-07 Jonathan Wakely * include/std/mutex (call_once): Store closure in __once_functor diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h index 65585184c86..e1f4d41a6d0 100644 --- a/libstdc++-v3/include/bits/alloc_traits.h +++ b/libstdc++-v3/include/bits/alloc_traits.h @@ -102,10 +102,8 @@ _GLIBCXX_ALLOC_TR_NESTED_TYPE(pointer, value_type*) */ typedef __pointer pointer; -// TODO: Use pointer_traits::rebind alias template. - _GLIBCXX_ALLOC_TR_NESTED_TYPE(const_pointer, - typename pointer_traits::template __rebind::__type) + typename pointer_traits::template rebind) /** * @brief The allocator's const pointer type. @@ -116,7 +114,7 @@ _GLIBCXX_ALLOC_TR_NESTED_TYPE(const_pointer, typedef __const_pointer const_pointer; _GLIBCXX_ALLOC_TR_NESTED_TYPE(void_pointer, - typename pointer_traits::template __rebind::__type) + typename pointer_traits::template rebind) /** * @brief The allocator's void pointer type. @@ -127,7 +125,7 @@ _GLIBCXX_ALLOC_TR_NESTED_TYPE(void_pointer, typedef __void_pointer void_pointer; _GLIBCXX_ALLOC_TR_NESTED_TYPE(const_void_pointer, - typename pointer_traits::template __rebind::__type) + typename pointer_traits::template rebind) /** * @brief The allocator's const void pointer type. @@ -196,23 +194,10 @@ _GLIBCXX_ALLOC_TR_NESTED_TYPE(propagate_on_container_swap, #undef _GLIBCXX_ALLOC_TR_NESTED_TYPE - /* TODO: use template alias template - using rebind_alloc = __alloctr_rebind<_Alloc, _Tp>::__type; + using rebind_alloc = typename __alloctr_rebind<_Alloc, _Tp>::__type; template using rebind_traits = allocator_traits>; - */ - template - struct __rebind_alloc - { - typedef typename __alloctr_rebind<_Alloc, _Tp>::__type __type; - }; - - template - struct __rebind_traits - { - typedef allocator_traits::__type> __type; - }; private: template diff --git a/libstdc++-v3/include/bits/ptr_traits.h b/libstdc++-v3/include/bits/ptr_traits.h index 4d33722c6d1..7f120b1f8ac 100644 --- a/libstdc++-v3/include/bits/ptr_traits.h +++ b/libstdc++-v3/include/bits/ptr_traits.h @@ -86,46 +86,19 @@ _GLIBCXX_HAS_NESTED_TYPE(difference_type) static const bool __value = _S_chk<_Ptr, _Up>(nullptr); }; - // hack to use _Tp::__rebind<_Up>::__type instead if that exists - template - class __ptrtr_rebind_helper2 - { - template - static constexpr bool - _S_chk(typename _Ptr2::template __rebind<_Up2>::__type*) - { return true; } - - template - static constexpr bool - _S_chk(...) - { return false; } - - public: - static const bool __value = _S_chk<_Ptr, _Up>(nullptr); - }; - - /* 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> struct __ptrtr_rebind; - template - struct __ptrtr_rebind<_Tp, _Up, true, _B2> + template + struct __ptrtr_rebind<_Tp, _Up, true> { typedef typename _Tp::template rebind<_Up> __type; }; - /* TODO: remove this when alias templates are supported */ - template - struct __ptrtr_rebind<_Tp, _Up, false, true> - { - typedef typename _Tp::template __rebind<_Up>::__type __type; - }; - template class _SomePtr, typename _Up, typename _Tp, typename... _Args> - struct __ptrtr_rebind<_SomePtr<_Tp, _Args...>, _Up, false, false> + struct __ptrtr_rebind<_SomePtr<_Tp, _Args...>, _Up, false> { typedef _SomePtr<_Up, _Args...> __type; }; @@ -168,14 +141,8 @@ _GLIBCXX_HAS_NESTED_TYPE(difference_type) typedef typename __ptrtr_diff_type<_Ptr>::__type difference_type; private: - /* TODO: replace __rebind with alias template rebind */ - /* template - using rebind<_Up> = typename __ptrtr_rebind<_Ptr, _Up>::__type; - */ - template - struct __rebind - { typedef typename __ptrtr_rebind<_Ptr, _Up>::__type __type; }; + using rebind = typename __ptrtr_rebind<_Ptr, _Up>::__type; // allocator_traits needs to use __rebind template friend struct allocator_traits; @@ -197,13 +164,8 @@ _GLIBCXX_HAS_NESTED_TYPE(difference_type) /// Type used to represent the difference between two pointers typedef ptrdiff_t difference_type; - /* TODO: replace __rebind with alias template rebind */ - /* template - using rebind<_Up> = U*; - */ - template - struct __rebind { typedef U* __type; }; + using rebind = _Up*; /** * @brief Obtain a pointer to an object diff --git a/libstdc++-v3/include/ext/alloc_traits.h b/libstdc++-v3/include/ext/alloc_traits.h index de13b652521..4862636645e 100644 --- a/libstdc++-v3/include/ext/alloc_traits.h +++ b/libstdc++-v3/include/ext/alloc_traits.h @@ -161,7 +161,7 @@ template template struct rebind - { typedef typename _Base_type::template __rebind_alloc<_Tp>::__type other; }; + { typedef typename _Base_type::template rebind_alloc<_Tp> other; }; #else typedef typename _Alloc::pointer pointer; diff --git a/libstdc++-v3/include/ext/pointer.h b/libstdc++-v3/include/ext/pointer.h index 9877e14d3c4..45fed19993e 100644 --- a/libstdc++-v3/include/ext/pointer.h +++ b/libstdc++-v3/include/ext/pointer.h @@ -577,21 +577,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// 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< + using rebind = 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; - }; static pointer pointer_to(typename pointer::reference __r) noexcept { return pointer(std::addressof(__r)); } diff --git a/libstdc++-v3/include/std/scoped_allocator b/libstdc++-v3/include/std/scoped_allocator index 9fd53db6133..edace9840d1 100644 --- a/libstdc++-v3/include/std/scoped_allocator +++ b/libstdc++-v3/include/std/scoped_allocator @@ -267,9 +267,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct rebind { - // TODO: use rebind_alloc instead of __rebind_alloc::__type typedef scoped_allocator_adaptor< - typename __traits::template __rebind_alloc<_Tp>::__type, + typename __traits::template rebind_alloc<_Tp>, _InnerAllocs...> other; };