+2011-11-08 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ * 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 <jwakely.gcc@gmail.com>
* include/std/mutex (call_once): Store closure in __once_functor
*/
typedef __pointer pointer;
-// TODO: Use pointer_traits::rebind alias template.
-
_GLIBCXX_ALLOC_TR_NESTED_TYPE(const_pointer,
- typename pointer_traits<pointer>::template __rebind<const value_type>::__type)
+ typename pointer_traits<pointer>::template rebind<const value_type>)
/**
* @brief The allocator's const pointer type.
typedef __const_pointer const_pointer;
_GLIBCXX_ALLOC_TR_NESTED_TYPE(void_pointer,
- typename pointer_traits<pointer>::template __rebind<void>::__type)
+ typename pointer_traits<pointer>::template rebind<void>)
/**
* @brief The allocator's void pointer type.
typedef __void_pointer void_pointer;
_GLIBCXX_ALLOC_TR_NESTED_TYPE(const_void_pointer,
- typename pointer_traits<pointer>::template __rebind<const void>::__type)
+ typename pointer_traits<pointer>::template rebind<const void>)
/**
* @brief The allocator's const void pointer type.
#undef _GLIBCXX_ALLOC_TR_NESTED_TYPE
- /* TODO: use template alias
template<typename _Tp>
- using rebind_alloc = __alloctr_rebind<_Alloc, _Tp>::__type;
+ using rebind_alloc = typename __alloctr_rebind<_Alloc, _Tp>::__type;
template<typename _Tp>
using rebind_traits = allocator_traits<rebind_alloc<_Tp>>;
- */
- template<typename _Tp>
- struct __rebind_alloc
- {
- typedef typename __alloctr_rebind<_Alloc, _Tp>::__type __type;
- };
-
- template<typename _Tp>
- struct __rebind_traits
- {
- typedef allocator_traits<typename __rebind_alloc<_Tp>::__type> __type;
- };
private:
template<typename _Alloc2>
static const bool __value = _S_chk<_Ptr, _Up>(nullptr);
};
- // hack to use _Tp::__rebind<_Up>::__type instead if that exists
- template<typename _Ptr, typename _Up>
- class __ptrtr_rebind_helper2
- {
- template<typename _Ptr2, typename _Up2>
- static constexpr bool
- _S_chk(typename _Ptr2::template __rebind<_Up2>::__type*)
- { return true; }
-
- template<typename, typename>
- 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<typename _Tp, typename _Up,
- bool = __ptrtr_rebind_helper<_Tp, _Up>::__value,
- bool = __ptrtr_rebind_helper2<_Tp, _Up>::__value>
+ bool = __ptrtr_rebind_helper<_Tp, _Up>::__value>
struct __ptrtr_rebind;
- template<typename _Tp, typename _Up, bool _B2>
- struct __ptrtr_rebind<_Tp, _Up, true, _B2>
- {
- typedef typename _Tp::template rebind<_Up> __type;
- };
-
- /* TODO: remove this when alias templates are supported */
template<typename _Tp, typename _Up>
- struct __ptrtr_rebind<_Tp, _Up, false, true>
+ struct __ptrtr_rebind<_Tp, _Up, true>
{
- typedef typename _Tp::template __rebind<_Up>::__type __type;
+ typedef typename _Tp::template rebind<_Up> __type;
};
template<template<typename, typename...> 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;
};
typedef typename __ptrtr_diff_type<_Ptr>::__type difference_type;
private:
- /* TODO: replace __rebind<U> with alias template rebind<U> */
- /*
template<typename _Up>
- using rebind<_Up> = typename __ptrtr_rebind<_Ptr, _Up>::__type;
- */
- template<typename _Up>
- 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<typename> friend struct allocator_traits;
/// Type used to represent the difference between two pointers
typedef ptrdiff_t difference_type;
- /* TODO: replace __rebind<U> with alias template rebind<U> */
- /*
template<typename _Up>
- using rebind<_Up> = U*;
- */
- template<typename U>
- struct __rebind { typedef U* __type; };
+ using rebind = _Up*;
/**
* @brief Obtain a pointer to an object
/// Type used to represent the difference between two pointers
typedef typename pointer::difference_type difference_type;
- /* TODO: replace __rebind<U> with alias template rebind<U> */
- /*
template<typename _Up>
- using rebind<_Up> = typename __gnu_cxx::_Pointer_adapter<
+ using rebind = typename __gnu_cxx::_Pointer_adapter<
typename pointer_traits<_Storage_policy>::rebind<_Up>>
- */
- template<typename _Up>
- 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)); }