diff --git a/include/unordered_set b/include/unordered_set index b5b73478..fd378fa0 100644 --- a/include/unordered_set +++ b/include/unordered_set @@ -68,6 +68,16 @@ 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 + template <class InputIterator> + unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14 + template <class InputIterator> + unordered_set(InputIterator f, InputIterator l, size_type n, + const hasher& hf, const allocator_type& a); // C++14 + 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 hasher& hf, const allocator_type& a); // C++14 ~unordered_set(); unordered_set& operator=(const unordered_set&); unordered_set& operator=(unordered_set&&) @@ -207,6 +217,16 @@ 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 + template <class InputIterator> + unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14 + template <class InputIterator> + unordered_multiset(InputIterator f, InputIterator l, size_type n, + const hasher& hf, const allocator_type& a); // C++14 + 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 hasher& hf, const allocator_type& a); // C++14 ~unordered_multiset(); unordered_multiset& operator=(const unordered_multiset&); unordered_multiset& operator=(unordered_multiset&&) @@ -353,6 +373,14 @@ public: } explicit unordered_set(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(size_type __n, const allocator_type& __a) + : unordered_set(__n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_set(__n, __hf, key_equal(), __a) {} +#endif unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); template <class _InputIterator> @@ -365,6 +393,17 @@ public: unordered_set(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, const allocator_type& __a) + : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {} + template <class _InputIterator> + 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 explicit unordered_set(const allocator_type& __a); unordered_set(const unordered_set& __u); unordered_set(const unordered_set& __u, const allocator_type& __a); @@ -381,6 +420,16 @@ public: unordered_set(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(initializer_list<value_type> __il, size_type __n, + const allocator_type& __a) + : unordered_set(__il, __n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + 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_HAS_NO_GENERALIZED_INITIALIZERS // ~unordered_set() = default; _LIBCPP_INLINE_VISIBILITY @@ -861,6 +910,14 @@ public: const key_equal& __eql = key_equal()); unordered_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(size_type __n, const allocator_type& __a) + : unordered_multiset(__n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multiset(__n, __hf, key_equal(), __a) {} +#endif template <class _InputIterator> unordered_multiset(_InputIterator __first, _InputIterator __last); template <class _InputIterator> @@ -871,6 +928,18 @@ public: unordered_multiset(_InputIterator __first, _InputIterator __last, size_type __n , const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, const allocator_type& __a) + : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {} + template <class _InputIterator> + inline _LIBCPP_INLINE_VISIBILITY + 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 explicit unordered_multiset(const allocator_type& __a); unordered_multiset(const unordered_multiset& __u); unordered_multiset(const unordered_multiset& __u, const allocator_type& __a); @@ -887,6 +956,14 @@ public: unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) + : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + 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_HAS_NO_GENERALIZED_INITIALIZERS // ~unordered_multiset() = default; _LIBCPP_INLINE_VISIBILITY diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp index db8ba0e7..af9dd01b 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp @@ -61,5 +61,49 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef NotConstructible T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + + A a(43); + C c(3, a); + assert(c.bucket_count() == 3); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp ()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } + { + typedef NotConstructible T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + + HF hf(42); + A a(43); + C c(4, hf, a); + assert(c.bucket_count() == 4); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp ()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif #endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp index 29729b5a..3578d35e 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp @@ -88,6 +88,76 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + + A a(42); + C c({ + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }, 12, a); + + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + + A a(42); + HF hf(43); + C c({ + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }, 12, hf, a); + + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp index 8c0828ae..1286eeef 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp @@ -93,5 +93,75 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + A a(42); + C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a); + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + HF hf(43); + A a(42); + C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a); + assert(c.bucket_count() >= 16); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp index 31878362..5d7897b9 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp @@ -61,5 +61,49 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef NotConstructible T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + + A a(43); + C c(3, a); + assert(c.bucket_count() == 3); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp ()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } + { + typedef NotConstructible T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + + HF hf(42); + A a(43); + C c(4, hf, a); + assert(c.bucket_count() == 4); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp ()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif #endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp index 8dc37e30..fcee4007 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp @@ -88,6 +88,76 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + + A a(42); + C c({ + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }, 12, a); + + assert(c.bucket_count() >= 12); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + + A a(42); + HF hf(43); + C c({ + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }, 12, hf, a); + + assert(c.bucket_count() >= 12); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp index 322fa3ff..d0166fab 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp @@ -93,5 +93,76 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + A a(42); + C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a); + assert(c.bucket_count() >= 12); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + HF hf(43); + A a(42); + C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a); + assert(c.bucket_count() >= 16); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + +#endif #endif }