[libc++] Enable missing allocator constructors in C++11 (#204845)

LWG2210 was a patch to N2554 (C++11) which added missing
allocator-extended constructors to various containers. When LWG2210 was
implemented, the constructors were gated with C++14. However, we
normally apply LWG issue resolutions as DRs.

This patch enables these constructors in C++11 mode too.

Fixes #204843

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
Co-authored-by: A. Jiang <de34@live.cn>
This commit is contained in:
halbi2 2026-07-09 19:46:26 -04:00 committed by GitHub
parent b2b67ba3b9
commit f5169f2a5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 159 additions and 144 deletions

View file

@ -153,7 +153,6 @@ public:
__guard.__complete();
}
#if _LIBCPP_STD_VER >= 14
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a)
: __layout_(__a) {
auto __guard = std::__make_exception_guard(__destroy_vector(*this));
@ -163,7 +162,6 @@ public:
}
__guard.__complete();
}
#endif
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x) {
auto __guard = std::__make_exception_guard(__destroy_vector(*this));

View file

@ -152,9 +152,7 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~vector() { __destroy_vector (*this)(); }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n);
#if _LIBCPP_STD_VER >= 14
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n, const allocator_type& __a);
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v);
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
vector(size_type __n, const value_type& __v, const allocator_type& __a);
@ -605,7 +603,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n)
}
}
#if _LIBCPP_STD_VER >= 14
template <class _Allocator>
_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
: __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) {
@ -615,7 +612,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, co
__size_ = __n;
}
}
#endif
template <class _Allocator>
_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)

View file

@ -40,7 +40,7 @@ public:
deque() noexcept(is_nothrow_default_constructible<allocator_type>::value);
explicit deque(const allocator_type& a);
explicit deque(size_type n);
explicit deque(size_type n, const allocator_type& a); // C++14
explicit deque(size_type n, const allocator_type& a);
deque(size_type n, const value_type& v);
deque(size_type n, const value_type& v, const allocator_type& a);
template <class InputIterator>
@ -644,9 +644,7 @@ public:
}
explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n);
# if _LIBCPP_STD_VER >= 14
explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const _Allocator& __a);
# endif
_LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v);
template <__enable_if_t<__is_allocator_v<_Allocator>, int> = 0>
@ -1323,7 +1321,6 @@ deque<_Tp, _Allocator>::deque(size_type __n) : __start_(0), __size_(0) {
__append(__n);
}
# if _LIBCPP_STD_VER >= 14
template <class _Tp, class _Allocator>
deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
: __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) {
@ -1331,7 +1328,6 @@ deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
if (__n > 0)
__append(__n);
}
# endif
template <class _Tp, class _Allocator>
deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0), __size_(0) {

View file

@ -37,7 +37,7 @@ public:
noexcept(is_nothrow_default_constructible<allocator_type>::value);
explicit forward_list(const allocator_type& a);
explicit forward_list(size_type n);
explicit forward_list(size_type n, const allocator_type& a); // C++14
explicit forward_list(size_type n, const allocator_type& a);
forward_list(size_type n, const value_type& v);
forward_list(size_type n, const value_type& v, const allocator_type& a);
template <class InputIterator>
@ -664,9 +664,7 @@ public:
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {} // = default;
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit forward_list(const allocator_type& __a);
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n);
# if _LIBCPP_STD_VER >= 14
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n, const allocator_type& __a);
# endif
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v);
template <__enable_if_t<__is_allocator_v<_Alloc>, int> = 0>
@ -941,7 +939,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type
}
}
# if _LIBCPP_STD_VER >= 14
template <class _Tp, class _Alloc>
_LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __base_alloc)
: __base(__base_alloc) {
@ -952,7 +949,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type
}
}
}
# endif
template <class _Tp, class _Alloc>
_LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) {

View file

@ -39,7 +39,7 @@ public:
noexcept(is_nothrow_default_constructible<allocator_type>::value);
explicit list(const allocator_type& a);
explicit list(size_type n);
explicit list(size_type n, const allocator_type& a); // C++14
explicit list(size_type n, const allocator_type& a);
list(size_type n, const value_type& value);
list(size_type n, const value_type& value, const allocator_type& a);
template <class Iter>
@ -708,9 +708,7 @@ public:
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {}
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : __base(__a) {}
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n);
# if _LIBCPP_STD_VER >= 14
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a);
# endif
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x);
template <__enable_if_t<__is_allocator_v<_Alloc>, int> = 0>
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
@ -1066,13 +1064,15 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n) {
# endif
}
# if _LIBCPP_STD_VER >= 14
template <class _Tp, class _Alloc>
_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : __base(__a) {
for (; __n > 0; --__n)
# ifndef _LIBCPP_CXX03_LANG
emplace_back();
}
# else
push_back(value_type());
# endif
}
template <class _Tp, class _Alloc>
_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) {

View file

@ -84,12 +84,12 @@ public:
constexpr map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
template <class InputIterator>
constexpr map(InputIterator first, InputIterator last, const allocator_type& a)
: map(first, last, Compare(), a) {} // C++14
: map(first, last, Compare(), a) {}
template<container-compatible-range<value_type> R>
constexpr map(from_range_t, R&& rg, const Allocator& a))
: map(from_range, std::forward<R>(rg), Compare(), a) { } // C++23
constexpr map(initializer_list<value_type> il, const allocator_type& a)
: map(il, Compare(), a) {} // C++14
: map(il, Compare(), a) {}
constexpr ~map();
constexpr map& operator=(const map& m);
@ -368,12 +368,12 @@ public:
const allocator_type& a);
template <class InputIterator>
multimap(InputIterator first, InputIterator last, const allocator_type& a)
: multimap(first, last, Compare(), a) {} // C++14
: multimap(first, last, Compare(), a) {}
template<container-compatible-range<value_type> R>
multimap(from_range_t, R&& rg, const Allocator& a))
: multimap(from_range, std::forward<R>(rg), Compare(), a) { } // C++23
multimap(initializer_list<value_type> il, const allocator_type& a)
: multimap(il, Compare(), a) {} // C++14
: multimap(il, Compare(), a) {}
~multimap();
multimap& operator=(const multimap& m);
@ -1035,12 +1035,10 @@ public:
}
# endif
# if _LIBCPP_STD_VER >= 14
template <class _InputIterator>
_LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX26 map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
: map(__f, __l, key_compare(), __a) {}
# endif
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<value_type> _Range>
@ -1073,10 +1071,8 @@ public:
insert(__il.begin(), __il.end());
}
# if _LIBCPP_STD_VER >= 14
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(initializer_list<value_type> __il, const allocator_type& __a)
: map(__il, key_compare(), __a) {}
# endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map& operator=(initializer_list<value_type> __il) {
clear();
@ -1817,12 +1813,10 @@ public:
}
# endif
# if _LIBCPP_STD_VER >= 14
template <class _InputIterator>
_LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX26 multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
: multimap(__f, __l, key_compare(), __a) {}
# endif
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<value_type> _Range>
@ -1856,11 +1850,9 @@ public:
insert(__il.begin(), __il.end());
}
# if _LIBCPP_STD_VER >= 14
_LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX26 multimap(initializer_list<value_type> __il, const allocator_type& __a)
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
multimap(initializer_list<value_type> __il, const allocator_type& __a)
: multimap(__il, key_compare(), __a) {}
# endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multimap& operator=(initializer_list<value_type> __il) {
clear();

View file

@ -71,12 +71,12 @@ public:
const allocator_type& a);
template <class InputIterator>
set(InputIterator first, InputIterator last, const allocator_type& a)
: set(first, last, Compare(), a) {} // C++14
: set(first, last, Compare(), a) {}
template<container-compatible-range<value_type> R>
set(from_range_t, R&& rg, const Allocator& a))
: set(from_range, std::forward<R>(rg), Compare(), a) { } // C++23
set(initializer_list<value_type> il, const allocator_type& a)
: set(il, Compare(), a) {} // C++14
: set(il, Compare(), a) {}
~set();
set& operator=(const set& s);
@ -316,12 +316,12 @@ public:
const allocator_type& a);
template <class InputIterator>
multiset(InputIterator first, InputIterator last, const allocator_type& a)
: set(first, last, Compare(), a) {} // C++14
: set(first, last, Compare(), a) {}
template<container-compatible-range<value_type> R>
multiset(from_range_t, R&& rg, const Allocator& a))
: multiset(from_range, std::forward<R>(rg), Compare(), a) { } // C++23
multiset(initializer_list<value_type> il, const allocator_type& a)
: set(il, Compare(), a) {} // C++14
: set(il, Compare(), a) {}
~multiset();
multiset& operator=(const multiset& s);
@ -653,12 +653,10 @@ public:
}
# endif
# if _LIBCPP_STD_VER >= 14
template <class _InputIterator>
_LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX26 set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
: set(__f, __l, key_compare(), __a) {}
# endif
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<value_type> _Range>
@ -695,10 +693,8 @@ public:
insert(__il.begin(), __il.end());
}
# if _LIBCPP_STD_VER >= 14
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(initializer_list<value_type> __il, const allocator_type& __a)
: set(__il, key_compare(), __a) {}
# endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set& operator=(initializer_list<value_type> __il) {
clear();
@ -1195,12 +1191,10 @@ public:
insert(__f, __l);
}
# if _LIBCPP_STD_VER >= 14
template <class _InputIterator>
_LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX26 multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
: multiset(__f, __l, key_compare(), __a) {}
# endif
template <class _InputIterator>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
@ -1253,11 +1247,9 @@ public:
insert(__il.begin(), __il.end());
}
# if _LIBCPP_STD_VER >= 14
_LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX26 multiset(initializer_list<value_type> __il, const allocator_type& __a)
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
multiset(initializer_list<value_type> __il, const allocator_type& __a)
: multiset(__il, key_compare(), __a) {}
# endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multiset& operator=(initializer_list<value_type> __il) {
clear();

View file

@ -77,16 +77,16 @@ public:
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
unordered_map(size_type n, const allocator_type& a)
: unordered_map(n, hasher(), key_equal(), a) {} // C++14
: unordered_map(n, hasher(), key_equal(), a) {}
unordered_map(size_type n, const hasher& hf, const allocator_type& a)
: unordered_map(n, hf, key_equal(), a) {} // C++14
: unordered_map(n, hf, key_equal(), a) {}
template <class InputIterator>
unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
: unordered_map(f, l, n, hasher(), key_equal(), a) {} // C++14
: unordered_map(f, l, n, hasher(), key_equal(), a) {}
template <class InputIterator>
unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
const allocator_type& a)
: unordered_map(f, l, n, hf, key_equal(), a) {} // C++14
: unordered_map(f, l, n, hf, key_equal(), a) {}
template<container-compatible-range<value_type> R>
unordered_map(from_range_t, R&& rg, size_type n, const allocator_type& a)
: unordered_map(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
@ -94,10 +94,10 @@ public:
unordered_map(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
: unordered_map(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23
unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
: unordered_map(il, n, hasher(), key_equal(), a) {} // C++14
: unordered_map(il, n, hasher(), key_equal(), a) {}
unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
const allocator_type& a)
: unordered_map(il, n, hf, key_equal(), a) {} // C++14
: unordered_map(il, n, hf, key_equal(), a) {}
~unordered_map();
unordered_map& operator=(const unordered_map&);
unordered_map& operator=(unordered_map&&)
@ -363,16 +363,16 @@ public:
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
unordered_multimap(size_type n, const allocator_type& a)
: unordered_multimap(n, hasher(), key_equal(), a) {} // C++14
: unordered_multimap(n, hasher(), key_equal(), a) {}
unordered_multimap(size_type n, const hasher& hf, const allocator_type& a)
: unordered_multimap(n, hf, key_equal(), a) {} // C++14
: unordered_multimap(n, hf, key_equal(), a) {}
template <class InputIterator>
unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
: unordered_multimap(f, l, n, hasher(), key_equal(), a) {} // C++14
: unordered_multimap(f, l, n, hasher(), key_equal(), a) {}
template <class InputIterator>
unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf,
const allocator_type& a)
: unordered_multimap(f, l, n, hf, key_equal(), a) {} // C++14
: unordered_multimap(f, l, n, hf, key_equal(), a) {}
template<container-compatible-range<value_type> R>
unordered_multimap(from_range_t, R&& rg, size_type n, const allocator_type& a)
: unordered_multimap(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
@ -380,10 +380,10 @@ public:
unordered_multimap(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
: unordered_multimap(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23
unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a)
: unordered_multimap(il, n, hasher(), key_equal(), a) {} // C++14
: unordered_multimap(il, n, hasher(), key_equal(), a) {}
unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf,
const allocator_type& a)
: unordered_multimap(il, n, hf, key_equal(), a) {} // C++14
: unordered_multimap(il, n, hf, key_equal(), a) {}
~unordered_multimap();
unordered_multimap& operator=(const unordered_multimap&);
unordered_multimap& operator=(unordered_multimap&&)
@ -993,7 +993,6 @@ public:
const key_equal& __eql,
const allocator_type& __a);
# endif // _LIBCPP_CXX03_LANG
# if _LIBCPP_STD_VER >= 14
_LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const allocator_type& __a)
: unordered_map(__n, hasher(), key_equal(), __a) {}
_LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)
@ -1007,7 +1006,7 @@ public:
_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
: unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
# if _LIBCPP_STD_VER >= 23
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<value_type> _Range>
_LIBCPP_HIDE_FROM_ABI unordered_map(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
: unordered_map(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
@ -1016,8 +1015,9 @@ public:
_LIBCPP_HIDE_FROM_ABI
unordered_map(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
: unordered_map(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
# endif
# endif
# ifndef _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
: unordered_map(__il, __n, hasher(), key_equal(), __a) {}
_LIBCPP_HIDE_FROM_ABI
@ -1787,7 +1787,6 @@ public:
const key_equal& __eql,
const allocator_type& __a);
# endif // _LIBCPP_CXX03_LANG
# if _LIBCPP_STD_VER >= 14
_LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const allocator_type& __a)
: unordered_multimap(__n, hasher(), key_equal(), __a) {}
_LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)
@ -1801,7 +1800,7 @@ public:
_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
: unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
# if _LIBCPP_STD_VER >= 23
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<value_type> _Range>
_LIBCPP_HIDE_FROM_ABI unordered_multimap(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
: unordered_multimap(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
@ -1810,8 +1809,9 @@ public:
_LIBCPP_HIDE_FROM_ABI
unordered_multimap(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
: unordered_multimap(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
# endif
# endif
# ifndef _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
: unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
_LIBCPP_HIDE_FROM_ABI

View file

@ -76,22 +76,22 @@ public:
unordered_set(initializer_list<value_type>, size_type n = 0,
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
unordered_set(size_type n, const allocator_type& a); // C++14
unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14
unordered_set(size_type n, const allocator_type& a);
unordered_set(size_type n, const hasher& hf, const allocator_type& a);
template <class InputIterator>
unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a);
template <class InputIterator>
unordered_set(InputIterator f, InputIterator l, size_type n,
const hasher& hf, const allocator_type& a); // C++14
const hasher& hf, const allocator_type& a);
template<container-compatible-range<value_type> R>
unordered_set(from_range_t, R&& rg, size_type n, const allocator_type& a)
: unordered_set(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
template<container-compatible-range<value_type> R>
unordered_set(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
: unordered_set(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23
unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a);
unordered_set(initializer_list<value_type> il, size_type n,
const hasher& hf, const allocator_type& a); // C++14
const hasher& hf, const allocator_type& a);
~unordered_set();
unordered_set& operator=(const unordered_set&);
unordered_set& operator=(unordered_set&&)
@ -324,22 +324,22 @@ public:
unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
unordered_multiset(size_type n, const allocator_type& a); // C++14
unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14
unordered_multiset(size_type n, const allocator_type& a);
unordered_multiset(size_type n, const hasher& hf, const allocator_type& a);
template <class InputIterator>
unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a);
template <class InputIterator>
unordered_multiset(InputIterator f, InputIterator l, size_type n,
const hasher& hf, const allocator_type& a); // C++14
const hasher& hf, const allocator_type& a);
template<container-compatible-range<value_type> R>
unordered_multiset(from_range_t, R&& rg, size_type n, const allocator_type& a)
: unordered_multiset(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
template<container-compatible-range<value_type> R>
unordered_multiset(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
: unordered_multiset(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23
unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a);
unordered_multiset(initializer_list<value_type> il, size_type n,
const hasher& hf, const allocator_type& a); // C++14
const hasher& hf, const allocator_type& a);
~unordered_multiset();
unordered_multiset& operator=(const unordered_multiset&);
unordered_multiset& operator=(unordered_multiset&&)
@ -634,12 +634,10 @@ public:
_LIBCPP_HIDE_FROM_ABI unordered_set() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
explicit _LIBCPP_HIDE_FROM_ABI
unordered_set(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
# if _LIBCPP_STD_VER >= 14
inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const allocator_type& __a)
: unordered_set(__n, hasher(), key_equal(), __a) {}
inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)
: unordered_set(__n, __hf, key_equal(), __a) {}
# endif
_LIBCPP_HIDE_FROM_ABI
unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);
template <class _InputIterator>
@ -677,7 +675,6 @@ public:
}
# endif
# if _LIBCPP_STD_VER >= 14
template <class _InputIterator>
inline _LIBCPP_HIDE_FROM_ABI
unordered_set(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
@ -686,7 +683,6 @@ public:
_LIBCPP_HIDE_FROM_ABI unordered_set(
_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
: unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
# endif
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<value_type> _Range>
@ -717,14 +713,12 @@ public:
const hasher& __hf,
const key_equal& __eql,
const allocator_type& __a);
# if _LIBCPP_STD_VER >= 14
inline _LIBCPP_HIDE_FROM_ABI
unordered_set(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
: unordered_set(__il, __n, hasher(), key_equal(), __a) {}
inline _LIBCPP_HIDE_FROM_ABI
unordered_set(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
: unordered_set(__il, __n, __hf, key_equal(), __a) {}
# endif
# endif // _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI ~unordered_set() {
static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
@ -1250,12 +1244,10 @@ public:
unordered_multiset(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
_LIBCPP_HIDE_FROM_ABI
unordered_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);
# if _LIBCPP_STD_VER >= 14
inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const allocator_type& __a)
: unordered_multiset(__n, hasher(), key_equal(), __a) {}
inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)
: unordered_multiset(__n, __hf, key_equal(), __a) {}
# endif
template <class _InputIterator>
_LIBCPP_HIDE_FROM_ABI unordered_multiset(_InputIterator __first, _InputIterator __last);
template <class _InputIterator>
@ -1291,7 +1283,6 @@ public:
}
# endif
# if _LIBCPP_STD_VER >= 14
template <class _InputIterator>
inline _LIBCPP_HIDE_FROM_ABI
unordered_multiset(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
@ -1300,7 +1291,6 @@ public:
inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(
_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
: unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
# endif
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<value_type> _Range>
@ -1331,14 +1321,12 @@ public:
const hasher& __hf,
const key_equal& __eql,
const allocator_type& __a);
# if _LIBCPP_STD_VER >= 14
inline _LIBCPP_HIDE_FROM_ABI
unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
: unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}
inline _LIBCPP_HIDE_FROM_ABI
unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
: unordered_multiset(__il, __n, __hf, key_equal(), __a) {}
# endif
# endif // _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI ~unordered_multiset() {
static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");

View file

@ -39,7 +39,7 @@ public:
noexcept(is_nothrow_default_constructible<allocator_type>::value);
explicit vector(const allocator_type&);
explicit vector(size_type n);
explicit vector(size_type n, const allocator_type&); // C++14
explicit vector(size_type n, const allocator_type&);
vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
template <class InputIterator>
vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type());
@ -171,7 +171,7 @@ public:
vector()
noexcept(is_nothrow_default_constructible<allocator_type>::value);
explicit vector(const allocator_type&) noexcept;
explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14
explicit vector(size_type n, const allocator_type& a = allocator_type());
vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
template <class InputIterator>
vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type());

View file

@ -72,7 +72,6 @@ TEST_CONSTEXPR_CXX26 bool test() {
assert(*std::next(m.begin()) == V(2, 1));
assert(*std::next(m.begin(), 2) == V(3, 1));
}
# if TEST_STD_VER > 11
{
typedef std::pair<const int, double> V;
V ar[] = {
@ -113,7 +112,6 @@ TEST_CONSTEXPR_CXX26 bool test() {
assert(m.get_allocator() == a);
}
}
# endif
#endif
return true;
}

View file

@ -115,6 +115,46 @@ bool test() {
assert(*std::next(m.begin(), 7) == V(3, 1.5));
assert(*std::next(m.begin(), 8) == V(3, 2));
}
{
typedef std::pair<const int, double> V;
V ar[] = {
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
};
{
typedef min_allocator<V> A;
typedef test_less<int> C;
A a;
std::multimap<int, double, C, A> m(ar, ar + sizeof(ar) / sizeof(ar[0]), a);
assert(m.size() == 9);
assert(std::distance(m.begin(), m.end()) == 9);
assert(*m.begin() == V(1, 1));
assert(*std::next(m.begin(), 3) == V(2, 1));
assert(*std::next(m.begin(), 6) == V(3, 1));
assert(m.get_allocator() == a);
}
{
typedef explicit_allocator<V> A;
typedef test_less<int> C;
A a;
std::multimap<int, double, C, A> m(ar, ar + sizeof(ar) / sizeof(ar[0]), a);
assert(m.size() == 9);
assert(std::distance(m.begin(), m.end()) == 9);
assert(*m.begin() == V(1, 1));
assert(*std::next(m.begin(), 3) == V(2, 1));
assert(*std::next(m.begin(), 6) == V(3, 1));
assert(m.get_allocator() == a);
}
}
#endif
return true;

View file

@ -48,7 +48,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
assert(*std::next(m.begin(), 7) == 3);
assert(*std::next(m.begin(), 8) == 3);
}
#if TEST_STD_VER > 11
#if TEST_STD_VER >= 11
{
typedef int V;
V ar[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};

View file

@ -46,7 +46,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
assert(*std::next(m.begin()) == 2);
assert(*std::next(m.begin(), 2) == 3);
}
#if TEST_STD_VER > 11
#if TEST_STD_VER >= 11
{
typedef int V;
V ar[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};

View file

@ -9,6 +9,7 @@
// <deque>
// explicit deque(size_type n);
// explicit deque(size_type n, const Allocator& a);
#include "asan_testing.h"
#include <deque>
@ -22,7 +23,7 @@
template <class T, class Allocator>
void test2(unsigned n) {
#if TEST_STD_VER > 11
#if TEST_STD_VER >= 11
typedef std::deque<T, Allocator> C;
typedef typename C::const_iterator const_iterator;
assert(DefaultOnly::count == 0);
@ -62,7 +63,7 @@ void test1(unsigned n) {
template <class T, class Allocator>
void test3(unsigned n, Allocator const& alloc = Allocator()) {
#if TEST_STD_VER > 11
#if TEST_STD_VER >= 11
typedef std::deque<T, Allocator> C;
{
C d(n, alloc);
@ -102,7 +103,7 @@ int main(int, char**) {
test<DefaultOnly, min_allocator<DefaultOnly> >(4095);
#endif
#if TEST_STD_VER > 11
#if TEST_STD_VER >= 11
test3<DefaultOnly, std::allocator<DefaultOnly>>(1023);
test3<int, std::allocator<int>>(1);
test3<int, min_allocator<int>>(3);

View file

@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
// XFAIL: FROZEN-CXX03-HEADERS-FIXME
// <forward_list>
// explicit forward_list(size_type n); // constexpr since C++26
@ -21,15 +23,10 @@
template <class T, class Allocator>
void check_allocator(unsigned n, Allocator const& alloc = Allocator()) {
#if TEST_STD_VER > 11
typedef std::forward_list<T, Allocator> C;
C d(n, alloc);
assert(d.get_allocator() == alloc);
assert(static_cast<std::size_t>(std::distance(d.begin(), d.end())) == n);
#else
((void)n);
((void)alloc);
#endif
}
int main(int, char**) {
@ -46,14 +43,24 @@ int main(int, char**) {
unsigned n = 0;
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) {
#if TEST_STD_VER >= 11
assert(*i == T());
#else
((void)0);
#endif
}
assert(n == N);
}
{
typedef DefaultOnly T;
typedef std::forward_list<T, std::allocator<T> > C;
unsigned N = 10;
C c(N, std::allocator<T>());
unsigned n = 0;
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) {
assert(*i == T());
}
assert(n == N);
check_allocator<T, std::allocator<T> >(0);
check_allocator<T, std::allocator<T> >(3);
}
#if TEST_STD_VER >= 11
{
typedef DefaultOnly T;

View file

@ -6,9 +6,12 @@
//
//===----------------------------------------------------------------------===//
// XFAIL: FROZEN-CXX03-HEADERS-FIXME
// <list>
// explicit list(size_type n); // constexpr since C++26
// explicit list(size_type n); // constexpr since C++26
// explicit list(size_type n, const Allocator& a); // constexpr since C++26
#include <list>
#include <cassert>
@ -21,7 +24,6 @@
template <class T, class Allocator>
TEST_CONSTEXPR_CXX26 void test1(unsigned n, Allocator const& alloc = Allocator()) {
#if TEST_STD_VER > 11
typedef std::list<T, Allocator> C;
{
C d(n, alloc);
@ -29,10 +31,6 @@ TEST_CONSTEXPR_CXX26 void test1(unsigned n, Allocator const& alloc = Allocator()
assert(static_cast<std::size_t>(std::distance(d.begin(), d.end())) == n);
assert(d.get_allocator() == alloc);
}
#else
((void)n);
((void)alloc);
#endif
}
TEST_CONSTEXPR_CXX26 bool test() {
@ -59,7 +57,19 @@ TEST_CONSTEXPR_CXX26 bool test() {
++i;
assert(*i == 0);
}
#if TEST_STD_VER > 11
{
std::list<int, std::allocator<int> > l(3, std::allocator<int>());
assert(l.size() == 3);
assert(std::distance(l.begin(), l.end()) == 3);
std::list<int, std::allocator<int> >::const_iterator i = l.begin();
assert(*i == 0);
++i;
assert(*i == 0);
++i;
assert(*i == 0);
test1<int, std::allocator<int> >(3);
}
#if TEST_STD_VER >= 11
{
typedef std::list<int, min_allocator<int> > C;
C l(3, min_allocator<int>());

View file

@ -10,6 +10,7 @@
// vector<bool>
// explicit vector(size_type n);
// explicit vector(size_type n, const Allocator& alloc = Allocator());
#include <vector>
#include <cassert>
@ -21,7 +22,7 @@
template <class C>
TEST_CONSTEXPR_CXX20 void
test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type()) {
#if TEST_STD_VER >= 14
#if TEST_STD_VER >= 11
C c(n, a);
LIBCPP_ASSERT(c.__invariants());
assert(c.size() == n);

View file

@ -38,7 +38,7 @@ test(typename C::size_type n, typename C::allocator_type const& a = typename C::
}
// Test with a custom allocator
#if TEST_STD_VER >= 14
#if TEST_STD_VER >= 11
{
C c(n, a);
LIBCPP_ASSERT(c.__invariants());

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_map>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_map>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_map>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_map>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_map>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_map>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_map>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_map>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_map>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_map>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_map>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_map>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_set>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_set>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_set>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_set>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_set>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_set>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_set>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_set>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_set>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_set>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_set>

View file

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03
// <unordered_set>