Support allocators with explicit conversion constructors. Fixes bug #29000
llvm-svn: 278904
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 2a10c960fa33b7048b48107823f5879cf301dece
diff --git a/include/map b/include/map
index b8aa7a6..bdde949 100644
--- a/include/map
+++ b/include/map
@@ -873,7 +873,7 @@
_LIBCPP_INLINE_VISIBILITY
explicit map(const key_compare& __comp, const allocator_type& __a)
- : __tree_(__vc(__comp), __a) {}
+ : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
@@ -888,7 +888,7 @@
_LIBCPP_INLINE_VISIBILITY
map(_InputIterator __f, _InputIterator __l,
const key_compare& __comp, const allocator_type& __a)
- : __tree_(__vc(__comp), __a)
+ : __tree_(__vc(__comp), typename __base::allocator_type(__a))
{
insert(__f, __l);
}
@@ -955,7 +955,7 @@
_LIBCPP_INLINE_VISIBILITY
map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
- : __tree_(__vc(__comp), __a)
+ : __tree_(__vc(__comp), typename __base::allocator_type(__a))
{
insert(__il.begin(), __il.end());
}
@@ -977,13 +977,13 @@
_LIBCPP_INLINE_VISIBILITY
explicit map(const allocator_type& __a)
- : __tree_(__a)
+ : __tree_(typename __base::allocator_type(__a))
{
}
_LIBCPP_INLINE_VISIBILITY
map(const map& __m, const allocator_type& __a)
- : __tree_(__m.__tree_.value_comp(), __a)
+ : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a))
{
insert(__m.begin(), __m.end());
}
@@ -1034,7 +1034,7 @@
const mapped_type& at(const key_type& __k) const;
_LIBCPP_INLINE_VISIBILITY
- allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
+ allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());}
_LIBCPP_INLINE_VISIBILITY
key_compare key_comp() const {return __tree_.value_comp().key_comp();}
_LIBCPP_INLINE_VISIBILITY
@@ -1367,7 +1367,7 @@
template <class _Key, class _Tp, class _Compare, class _Allocator>
map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
- : __tree_(_VSTD::move(__m.__tree_), __a)
+ : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a))
{
if (__a != __m.get_allocator())
{
@@ -1599,7 +1599,7 @@
_LIBCPP_INLINE_VISIBILITY
explicit multimap(const key_compare& __comp, const allocator_type& __a)
- : __tree_(__vc(__comp), __a) {}
+ : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
@@ -1614,7 +1614,7 @@
_LIBCPP_INLINE_VISIBILITY
multimap(_InputIterator __f, _InputIterator __l,
const key_compare& __comp, const allocator_type& __a)
- : __tree_(__vc(__comp), __a)
+ : __tree_(__vc(__comp), typename __base::allocator_type(__a))
{
insert(__f, __l);
}
@@ -1682,7 +1682,7 @@
_LIBCPP_INLINE_VISIBILITY
multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
- : __tree_(__vc(__comp), __a)
+ : __tree_(__vc(__comp), typename __base::allocator_type(__a))
{
insert(__il.begin(), __il.end());
}
@@ -1704,13 +1704,13 @@
_LIBCPP_INLINE_VISIBILITY
explicit multimap(const allocator_type& __a)
- : __tree_(__a)
+ : __tree_(typename __base::allocator_type(__a))
{
}
_LIBCPP_INLINE_VISIBILITY
multimap(const multimap& __m, const allocator_type& __a)
- : __tree_(__m.__tree_.value_comp(), __a)
+ : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a))
{
insert(__m.begin(), __m.end());
}
@@ -1752,7 +1752,7 @@
size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
_LIBCPP_INLINE_VISIBILITY
- allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
+ allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());}
_LIBCPP_INLINE_VISIBILITY
key_compare key_comp() const {return __tree_.value_comp().key_comp();}
_LIBCPP_INLINE_VISIBILITY
@@ -1923,7 +1923,7 @@
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Tp, class _Compare, class _Allocator>
multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)
- : __tree_(_VSTD::move(__m.__tree_), __a)
+ : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a))
{
if (__a != __m.get_allocator())
{
diff --git a/include/unordered_map b/include/unordered_map
index bf64ad6..8d7edaf 100644
--- a/include/unordered_map
+++ b/include/unordered_map
@@ -1185,7 +1185,7 @@
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a)
- : __table_(__hf, __eql, __a)
+ : __table_(__hf, __eql, typename __table::allocator_type(__a))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1197,7 +1197,7 @@
inline
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
const allocator_type& __a)
- : __table_(__a)
+ : __table_(typename __table::allocator_type(__a))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1234,7 +1234,7 @@
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
- : __table_(__hf, __eql, __a)
+ : __table_(__hf, __eql, typename __table::allocator_type(__a))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1258,7 +1258,7 @@
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
const unordered_map& __u, const allocator_type& __a)
- : __table_(__u.__table_, __a)
+ : __table_(__u.__table_, typename __table::allocator_type(__a))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1285,7 +1285,7 @@
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
unordered_map&& __u, const allocator_type& __a)
- : __table_(_VSTD::move(__u.__table_), __a)
+ : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1335,7 +1335,7 @@
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
initializer_list<value_type> __il, size_type __n, const hasher& __hf,
const key_equal& __eql, const allocator_type& __a)
- : __table_(__hf, __eql, __a)
+ : __table_(__hf, __eql, typename __table::allocator_type(__a))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1820,7 +1820,7 @@
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a)
- : __table_(__hf, __eql, __a)
+ : __table_(__hf, __eql, typename __table::allocator_type(__a))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1858,7 +1858,7 @@
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
- : __table_(__hf, __eql, __a)
+ : __table_(__hf, __eql, typename __table::allocator_type(__a))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1871,7 +1871,7 @@
inline
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
const allocator_type& __a)
- : __table_(__a)
+ : __table_(typename __table::allocator_type(__a))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1893,7 +1893,7 @@
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
const unordered_multimap& __u, const allocator_type& __a)
- : __table_(__u.__table_, __a)
+ : __table_(__u.__table_, typename __table::allocator_type(__a))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1920,7 +1920,7 @@
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
unordered_multimap&& __u, const allocator_type& __a)
- : __table_(_VSTD::move(__u.__table_), __a)
+ : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1972,7 +1972,7 @@
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
initializer_list<value_type> __il, size_type __n, const hasher& __hf,
const key_equal& __eql, const allocator_type& __a)
- : __table_(__hf, __eql, __a)
+ : __table_(__hf, __eql, typename __table::allocator_type(__a))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);