In many places, there was an #ifdef/#else block that selected one of two implmentations of rebind_alloc based on whether or not we had template aliases. Create a helper struct to encapsulate that bit of logic, and replace all the ifdefs with uses of that struct. No functionality change intented.

llvm-svn: 234296
This commit is contained in:
Marshall Clow 2015-04-07 05:21:38 +00:00
parent 1c0844bdfb
commit 1f508014df
12 changed files with 37 additions and 161 deletions

View File

@ -798,13 +798,7 @@ function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
}
else
{
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<_FF>
#else
rebind_alloc<_FF>::other
#endif
_Ap;
typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@ -1100,13 +1094,7 @@ function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
}
else
{
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<_FF>
#else
rebind_alloc<_FF>::other
#endif
_Ap;
typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@ -1402,13 +1390,7 @@ function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
}
else
{
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<_FF>
#else
rebind_alloc<_FF>::other
#endif
_Ap;
typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@ -1704,13 +1686,7 @@ function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp
}
else
{
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<_FF>
#else
rebind_alloc<_FF>::other
#endif
_Ap;
typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));

View File

@ -775,13 +775,7 @@ public:
public:
// Create __node
typedef __hash_node<value_type, typename __alloc_traits::void_pointer> __node;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__node>
#else
rebind_alloc<__node>::other
#endif
__node_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
typedef allocator_traits<__node_allocator> __node_traits;
typedef typename __node_traits::pointer __node_pointer;
typedef typename __node_traits::pointer __node_const_pointer;
@ -796,13 +790,7 @@ public:
private:
typedef typename __node_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__node_pointer>
#else
rebind_alloc<__node_pointer>::other
#endif
__pointer_allocator;
typedef typename __rebind_alloc_helper<__node_traits, __node_pointer>::type __pointer_allocator;
typedef __bucket_list_deallocator<__pointer_allocator> __bucket_list_deleter;
typedef unique_ptr<__node_pointer[], __bucket_list_deleter> __bucket_list;
typedef allocator_traits<__pointer_allocator> __pointer_alloc_traits;

View File

@ -802,13 +802,7 @@ public:
typedef __tree_node<value_type, __void_pointer> __node;
typedef __tree_node_base<__void_pointer> __node_base;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__node>
#else
rebind_alloc<__node>::other
#endif
__node_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
typedef allocator_traits<__node_allocator> __node_traits;
typedef typename __node_traits::pointer __node_pointer;
typedef typename __node_traits::pointer __node_const_pointer;

View File

@ -912,22 +912,10 @@ protected:
static const difference_type __block_size = sizeof(value_type) < 256 ? 4096 / sizeof(value_type) : 16;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<pointer>
#else
rebind_alloc<pointer>::other
#endif
__pointer_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, pointer>::type __pointer_allocator;
typedef allocator_traits<__pointer_allocator> __map_traits;
typedef typename __map_traits::pointer __map_pointer;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<const_pointer>
#else
rebind_alloc<const_pointer>::other
#endif
__const_pointer_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, const_pointer>::type __const_pointer_allocator;
typedef typename allocator_traits<__const_pointer_allocator>::const_pointer __map_const_pointer;
typedef __split_buffer<pointer, __pointer_allocator> __map;

View File

@ -493,13 +493,7 @@ private:
typedef pair<key_type, mapped_type> __value_type;
typedef __hash_map_hasher<__value_type, hasher> __hasher;
typedef __hash_map_equal<__value_type, key_equal> __key_equal;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@ -772,13 +766,7 @@ private:
typedef pair<key_type, mapped_type> __value_type;
typedef __hash_map_hasher<__value_type, hasher> __hasher;
typedef __hash_map_equal<__value_type, key_equal> __key_equal;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;

View File

@ -365,24 +365,12 @@ protected:
typedef typename allocator_traits<allocator_type>::void_pointer void_pointer;
typedef __forward_list_node<value_type, void_pointer> __node;
typedef typename __begin_node_of<value_type, void_pointer>::type __begin_node;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__node>
#else
rebind_alloc<__node>::other
#endif
__node_allocator;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __node>::type __node_allocator;
typedef allocator_traits<__node_allocator> __node_traits;
typedef typename __node_traits::pointer __node_pointer;
typedef typename __node_traits::pointer __node_const_pointer;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__begin_node>
#else
rebind_alloc<__begin_node>::other
#endif
__begin_node_allocator;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __begin_node>::type __begin_node_allocator;
typedef typename allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer;
__compressed_pair<__begin_node, __node_allocator> __before_begin_;

View File

@ -1368,13 +1368,7 @@ __base<_Rp(_ArgTypes...)>*
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
{
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__func>
#else
rebind_alloc<__func>::other
#endif
_Ap;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@ -1401,13 +1395,7 @@ void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
{
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__func>
#else
rebind_alloc<__func>::other
#endif
_Ap;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
__f_.~__compressed_pair<_Fp, _Alloc>();
__a.deallocate(this, 1);
@ -1668,13 +1656,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _
if (__not_null(__f))
{
typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<_FF>
#else
rebind_alloc<_FF>::other
#endif
_Ap;
typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
_Ap __a(__a0);
if (sizeof(_FF) <= sizeof(__buf_) &&
is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)

View File

@ -515,13 +515,7 @@ protected:
typedef __list_const_iterator<value_type, __void_pointer> const_iterator;
typedef __list_node_base<value_type, __void_pointer> __node_base;
typedef __list_node<value_type, __void_pointer> __node;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__node>
#else
rebind_alloc<__node>::other
#endif
__node_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
typedef allocator_traits<__node_allocator> __node_alloc_traits;
typedef typename __node_alloc_traits::pointer __node_pointer;
typedef typename __node_alloc_traits::pointer __node_const_pointer;
@ -529,13 +523,7 @@ protected:
typedef typename __alloc_traits::const_pointer const_pointer;
typedef typename __alloc_traits::difference_type difference_type;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__node_base>
#else
rebind_alloc<__node_base>::other
#endif
__node_base_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, __node_base>::type __node_base_allocator;
typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer;
__node_base __end_;

View File

@ -822,13 +822,8 @@ private:
typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
__value_type>::type __allocator_type;
typedef __tree<__value_type, __vc, __allocator_type> __base;
typedef typename __base::__node_traits __node_traits;
typedef allocator_traits<allocator_type> __alloc_traits;
@ -1568,13 +1563,8 @@ private:
typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
__value_type>::type __allocator_type;
typedef __tree<__value_type, __vc, __allocator_type> __base;
typedef typename __base::__node_traits __node_traits;
typedef allocator_traits<allocator_type> __alloc_traits;

View File

@ -1635,6 +1635,16 @@ private:
{return __a;}
};
template <class _Traits, class _Tp>
struct __rebind_alloc_helper
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
typedef typename _Traits::template rebind_alloc<_Tp> type;
#else
typedef typename _Traits::template rebind_alloc<_Tp>::other type;
#endif
};
// allocator
template <class _Tp>

View File

@ -730,13 +730,8 @@ private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
__value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@ -1469,13 +1464,8 @@ private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
__value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;

View File

@ -2125,13 +2125,7 @@ public:
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
private:
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__storage_type>
#else
rebind_alloc<__storage_type>::other
#endif
__storage_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator;
typedef allocator_traits<__storage_allocator> __storage_traits;
typedef typename __storage_traits::pointer __storage_pointer;
typedef typename __storage_traits::const_pointer __const_storage_pointer;