diff --git a/stl/CMakeLists.txt b/stl/CMakeLists.txt index 66bead9e16a..f399e60c92e 100644 --- a/stl/CMakeLists.txt +++ b/stl/CMakeLists.txt @@ -83,8 +83,6 @@ set(HEADERS ${CMAKE_CURRENT_LIST_DIR}/inc/functional ${CMAKE_CURRENT_LIST_DIR}/inc/future ${CMAKE_CURRENT_LIST_DIR}/inc/generator - ${CMAKE_CURRENT_LIST_DIR}/inc/hash_map - ${CMAKE_CURRENT_LIST_DIR}/inc/hash_set ${CMAKE_CURRENT_LIST_DIR}/inc/header-units.json ${CMAKE_CURRENT_LIST_DIR}/inc/initializer_list ${CMAKE_CURRENT_LIST_DIR}/inc/iomanip diff --git a/stl/inc/__msvc_all_public_headers.hpp b/stl/inc/__msvc_all_public_headers.hpp index e05d9e5dc32..ff36108473f 100644 --- a/stl/inc/__msvc_all_public_headers.hpp +++ b/stl/inc/__msvc_all_public_headers.hpp @@ -30,7 +30,6 @@ #define _SILENCE_CXX20_CISO646_REMOVED_WARNING #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING -#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS // Core STL Headers #include @@ -90,8 +89,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/stl/inc/hash_map b/stl/inc/hash_map deleted file mode 100644 index e43b4099a76..00000000000 --- a/stl/inc/hash_map +++ /dev/null @@ -1,465 +0,0 @@ -// hash_map extension header - -// Copyright (c) Microsoft Corporation. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#ifndef _HASH_MAP_ -#define _HASH_MAP_ -#include -#if _STL_COMPILER_PREPROCESSOR -#include - -#pragma pack(push, _CRT_PACKING) -#pragma warning(push, _STL_WARNING_LEVEL) -#pragma warning(disable : _STL_DISABLED_WARNINGS) -_STL_DISABLE_CLANG_WARNINGS -#pragma push_macro("new") -#undef new - -#ifndef _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -#error is deprecated and will be REMOVED. Please use . You can define \ -_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS to suppress this error. -#endif // _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS - -namespace stdext { - using _STD allocator; - using _STD enable_if_t; - using _STD is_constructible_v; - using _STD pair; - using _STD swap; - using _STD _Hash; - using _STD _Is_nothrow_swappable; - using _STD _Xout_of_range; - - template // true if multiple equivalent keys are permitted - class _Hmap_traits : public _Tr { // traits required to make _Hash behave like a map - public: - using key_type = _Kty; - using value_type = pair; - using _Mutable_value_type = pair<_Kty, _Ty>; - using key_compare = _Tr; - using allocator_type = _Alloc; -#if _HAS_CXX17 - using node_type = - _STD _Node_handle<_STD _List_node::void_pointer>, _Alloc, - _STD _Node_handle_map_base, _Kty, _Ty>; -#endif // _HAS_CXX17 - - static constexpr bool _Multi = _Mfl; - static constexpr bool _Standard = false; - - template - using _In_place_key_extractor = _STD _In_place_key_extract_map<_Kty, _Args...>; - - using key_equal = _Tr; - - static constexpr bool _Has_transparent_overloads = false; - - _Hmap_traits() = default; - - _Hmap_traits(const _Tr& _Traits) noexcept(_STD is_nothrow_copy_constructible_v<_Tr>) : _Tr(_Traits) {} - - class value_compare { - public: - using first_argument_type = value_type; - using second_argument_type = value_type; - using result_type = bool; - - _NODISCARD bool operator()(const value_type& _Left, const value_type& _Right) const - noexcept(noexcept(_Keycompobj(_Left.first, _Right.first))) { - // test if _Left precedes _Right by comparing just keys - return _Keycompobj(_Left.first, _Right.first); - } - - value_compare(const key_compare& _Keycomparg) noexcept(_STD is_nothrow_copy_constructible_v) - : _Keycompobj(_Keycomparg) {} - - key_compare _Keycompobj; - }; - - template - _NODISCARD static const _Kty& _Kfn(const pair<_Ty1, _Ty2>& _Val) noexcept { // extract key from element value - return _Val.first; - } - - _NODISCARD float& _Get_max_bucket_size() noexcept { - return _Max_buckets; - } - - _NODISCARD const float& _Get_max_bucket_size() const noexcept { - return _Max_buckets; - } - - void swap(_Hmap_traits& _Rhs) noexcept(_Is_nothrow_swappable<_Tr>::value) { - using _STD swap; - swap(static_cast<_Tr&>(*this), static_cast<_Tr&>(_Rhs)); // intentional ADL - _STD swap(_Max_buckets, _Rhs._Max_buckets); - } - - float _Max_buckets = 0.0F; // current maximum bucket size - }; - - template >, - class _Alloc = allocator>> - class hash_map : public _Hash<_Hmap_traits<_Kty, _Ty, _Tr, _Alloc, false>> { - // hash table of {key, mapped} values, unique keys - public: - using _Mybase = _Hash<_Hmap_traits<_Kty, _Ty, _Tr, _Alloc, false>>; - using key_type = _Kty; - using mapped_type = _Ty; - using referent_type = _Ty; - using key_compare = _Tr; - using value_compare = typename _Mybase::_Value_compare; - using value_type = pair; - using allocator_type = typename _Mybase::allocator_type; - using size_type = typename _Mybase::size_type; - using difference_type = typename _Mybase::difference_type; - using pointer = typename _Mybase::pointer; - using const_pointer = typename _Mybase::const_pointer; - using reference = value_type&; - using const_reference = const value_type&; - using iterator = typename _Mybase::iterator; - using const_iterator = typename _Mybase::const_iterator; - using _Alnode = typename _Mybase::_Alnode; - using _Alnode_traits = typename _Mybase::_Alnode_traits; -#if _HAS_CXX17 - using insert_return_type = _STD _Insert_return_type; -#endif // _HAS_CXX17 - - hash_map() : _Mybase(key_compare(), allocator_type()) {} - - explicit hash_map(const allocator_type& _Al) : _Mybase(key_compare(), _Al) {} - - hash_map(const hash_map& _Right) - : _Mybase(_Right, _Alnode_traits::select_on_container_copy_construction(_Right._Getal())) {} - - hash_map(const hash_map& _Right, const allocator_type& _Al) : _Mybase(_Right, _Al) {} - - explicit hash_map(const key_compare& _Traits) : _Mybase(_Traits, allocator_type()) {} - - hash_map(const key_compare& _Traits, const allocator_type& _Al) : _Mybase(_Traits, _Al) {} - - template - hash_map(_Iter _First, _Iter _Last) : _Mybase(key_compare(), allocator_type()) { - insert(_First, _Last); - } - - template - hash_map(_Iter _First, _Iter _Last, const key_compare& _Traits) : _Mybase(_Traits, allocator_type()) { - insert(_First, _Last); - } - - template - hash_map(_Iter _First, _Iter _Last, const key_compare& _Traits, const allocator_type& _Al) - : _Mybase(_Traits, _Al) { - insert(_First, _Last); - } - - hash_map& operator=(const hash_map& _Right) { - _Mybase::operator=(_Right); - return *this; - } - - hash_map(hash_map&& _Right) : _Mybase(_STD move(_Right)) {} - - hash_map(hash_map&& _Right, const allocator_type& _Al) : _Mybase(_STD move(_Right), _Al) {} - - hash_map& operator=(hash_map&& _Right) noexcept(noexcept(_Mybase::operator=(_STD move(_Right)))) { - _Mybase::operator=(_STD move(_Right)); - return *this; - } - - mapped_type& operator[](key_type&& _Keyval) { - return this->_Try_emplace(_STD move(_Keyval)).first->_Myval.second; - } - - void swap(hash_map& _Right) noexcept(noexcept(_Mybase::swap(_Right))) { - _Mybase::swap(_Right); - } - - using _Mybase::insert; - - template , int> = 0> - pair insert(_Valty&& _Val) { - return this->emplace(_STD forward<_Valty>(_Val)); - } - - template , int> = 0> - iterator insert(const_iterator _Where, _Valty&& _Val) { - return this->emplace_hint(_Where, _STD forward<_Valty>(_Val)); - } - - hash_map(_STD initializer_list _Ilist) : _Mybase(key_compare(), allocator_type()) { - insert(_Ilist); - } - - hash_map(_STD initializer_list _Ilist, const key_compare& _Pred) - : _Mybase(_Pred, allocator_type()) { - insert(_Ilist); - } - - hash_map(_STD initializer_list _Ilist, const key_compare& _Pred, const allocator_type& _Al) - : _Mybase(_Pred, _Al) { - insert(_Ilist); - } - - hash_map& operator=(_STD initializer_list _Ilist) { - this->clear(); - insert(_Ilist); - return *this; - } - - mapped_type& operator[](const key_type& _Keyval) { - return this->_Try_emplace(_Keyval).first->_Myval.second; - } - - _NODISCARD mapped_type& at(const key_type& _Keyval) { - const auto _Target = this->_Find_last(_Keyval, this->_Traitsobj(_Keyval)); - if (_Target._Duplicate) { - return _Target._Duplicate->_Myval.second; - } - - _Xout_of_range("invalid hash_map key"); - } - - _NODISCARD const mapped_type& at(const key_type& _Keyval) const { - const auto _Target = this->_Find_last(_Keyval, this->_Traitsobj(_Keyval)); - if (_Target._Duplicate) { - return _Target._Duplicate->_Myval.second; - } - - _Xout_of_range("invalid hash_map key"); - } - - using reverse_iterator = _STD reverse_iterator; - using const_reverse_iterator = _STD reverse_iterator; - - _NODISCARD reverse_iterator rbegin() noexcept { - return reverse_iterator(this->end()); - } - - _NODISCARD const_reverse_iterator rbegin() const noexcept { - return const_reverse_iterator(this->end()); - } - - _NODISCARD reverse_iterator rend() noexcept { - return reverse_iterator(this->begin()); - } - - _NODISCARD const_reverse_iterator rend() const noexcept { - return const_reverse_iterator(this->begin()); - } - - _NODISCARD const_reverse_iterator crbegin() const noexcept { - return rbegin(); - } - - _NODISCARD const_reverse_iterator crend() const noexcept { - return rend(); - } - - _NODISCARD key_compare key_comp() const { - return this->_Traitsobj; - } - - _NODISCARD value_compare value_comp() const { - return value_compare(key_comp()); - } - - using _Mybase::_Unchecked_begin; - using _Mybase::_Unchecked_end; - }; - - template - void swap(hash_map<_Kty, _Ty, _Tr, _Alloc>& _Left, hash_map<_Kty, _Ty, _Tr, _Alloc>& _Right) - noexcept(noexcept(_Left.swap(_Right))) { - _Left.swap(_Right); - } - - template - _NODISCARD bool operator==( - const hash_map<_Kty, _Ty, _Tr, _Alloc>& _Left, const hash_map<_Kty, _Ty, _Tr, _Alloc>& _Right) { - return _STD _Hash_equal(_Left, _Right); - } - - template - _NODISCARD bool operator!=( - const hash_map<_Kty, _Ty, _Tr, _Alloc>& _Left, const hash_map<_Kty, _Ty, _Tr, _Alloc>& _Right) { - return !(_Left == _Right); - } - - template >, - class _Alloc = allocator>> - class hash_multimap : public _Hash<_Hmap_traits<_Kty, _Ty, _Tr, _Alloc, true>> { - // hash table of {key, mapped} values, non-unique keys - public: - using _Mybase = _Hash<_Hmap_traits<_Kty, _Ty, _Tr, _Alloc, true>>; - using key_type = _Kty; - using mapped_type = _Ty; - using referent_type = _Ty; // old name, magically gone - using key_compare = _Tr; - using value_compare = typename _Mybase::_Value_compare; - using value_type = pair; - using allocator_type = typename _Mybase::allocator_type; - using size_type = typename _Mybase::size_type; - using difference_type = typename _Mybase::difference_type; - using pointer = typename _Mybase::pointer; - using const_pointer = typename _Mybase::const_pointer; - using reference = value_type&; - using const_reference = const value_type&; - using iterator = typename _Mybase::iterator; - using const_iterator = typename _Mybase::const_iterator; - using _Alnode = typename _Mybase::_Alnode; - using _Alnode_traits = typename _Mybase::_Alnode_traits; - - hash_multimap() : _Mybase(key_compare(), allocator_type()) {} - - explicit hash_multimap(const allocator_type& _Al) : _Mybase(key_compare(), _Al) {} - - hash_multimap(const hash_multimap& _Right) - : _Mybase(_Right, _Alnode_traits::select_on_container_copy_construction(_Right._Getal())) {} - - hash_multimap(const hash_multimap& _Right, const allocator_type& _Al) : _Mybase(_Right, _Al) {} - - explicit hash_multimap(const key_compare& _Traits) : _Mybase(_Traits, allocator_type()) {} - - hash_multimap(const key_compare& _Traits, const allocator_type& _Al) : _Mybase(_Traits, _Al) {} - - template - hash_multimap(_Iter _First, _Iter _Last) : _Mybase(key_compare(), allocator_type()) { - insert(_First, _Last); - } - - template - hash_multimap(_Iter _First, _Iter _Last, const key_compare& _Traits) : _Mybase(_Traits, allocator_type()) { - insert(_First, _Last); - } - - template - hash_multimap(_Iter _First, _Iter _Last, const key_compare& _Traits, const allocator_type& _Al) - : _Mybase(_Traits, _Al) { - insert(_First, _Last); - } - - hash_multimap& operator=(const hash_multimap& _Right) { - _Mybase::operator=(_Right); - return *this; - } - - hash_multimap(hash_multimap&& _Right) : _Mybase(_STD move(_Right)) {} - - hash_multimap(hash_multimap&& _Right, const allocator_type& _Al) : _Mybase(_STD move(_Right), _Al) {} - - hash_multimap& operator=(hash_multimap&& _Right) noexcept(noexcept(_Mybase::operator=(_STD move(_Right)))) { - _Mybase::operator=(_STD move(_Right)); - return *this; - } - - void swap(hash_multimap& _Right) noexcept(noexcept(_Mybase::swap(_Right))) { - _Mybase::swap(_Right); - } - - using _Mybase::insert; - - template , int> = 0> - iterator insert(_Valty&& _Val) { - return this->emplace(_STD forward<_Valty>(_Val)); - } - - template , int> = 0> - iterator insert(const_iterator _Where, _Valty&& _Val) { - return this->emplace_hint(_Where, _STD forward<_Valty>(_Val)); - } - - hash_multimap(_STD initializer_list _Ilist) : _Mybase(key_compare(), allocator_type()) { - insert(_Ilist); - } - - hash_multimap(_STD initializer_list _Ilist, const key_compare& _Pred) - : _Mybase(_Pred, allocator_type()) { - insert(_Ilist); - } - - hash_multimap(_STD initializer_list _Ilist, const key_compare& _Pred, const allocator_type& _Al) - : _Mybase(_Pred, _Al) { - insert(_Ilist); - } - - hash_multimap& operator=(_STD initializer_list _Ilist) { - this->clear(); - insert(_Ilist); - return *this; - } - - using reverse_iterator = _STD reverse_iterator; - using const_reverse_iterator = _STD reverse_iterator; - - _NODISCARD reverse_iterator rbegin() noexcept { - return reverse_iterator(this->end()); - } - - _NODISCARD const_reverse_iterator rbegin() const noexcept { - return const_reverse_iterator(this->end()); - } - - _NODISCARD reverse_iterator rend() noexcept { - return reverse_iterator(this->begin()); - } - - _NODISCARD const_reverse_iterator rend() const noexcept { - return const_reverse_iterator(this->begin()); - } - - _NODISCARD const_reverse_iterator crbegin() const noexcept { - return rbegin(); - } - - _NODISCARD const_reverse_iterator crend() const noexcept { - return rend(); - } - - _NODISCARD key_compare key_comp() const { - return this->_Traitsobj; - } - - _NODISCARD value_compare value_comp() const { - return value_compare(key_comp()); - } - - using _Mybase::_Unchecked_begin; - using _Mybase::_Unchecked_end; - }; - - template - void swap(hash_multimap<_Kty, _Ty, _Tr, _Alloc>& _Left, hash_multimap<_Kty, _Ty, _Tr, _Alloc>& _Right) - noexcept(noexcept(_Left.swap(_Right))) { - _Left.swap(_Right); - } - - template - _NODISCARD bool operator==( - const hash_multimap<_Kty, _Ty, _Tr, _Alloc>& _Left, const hash_multimap<_Kty, _Ty, _Tr, _Alloc>& _Right) { - return _STD _Hash_equal(_Left, _Right); - } - - template - _NODISCARD bool operator!=( - const hash_multimap<_Kty, _Ty, _Tr, _Alloc>& _Left, const hash_multimap<_Kty, _Ty, _Tr, _Alloc>& _Right) { - return !(_Left == _Right); - } -} // namespace stdext -_STD_BEGIN -using _STDEXT hash_map; -using _STDEXT hash_multimap; -_STD_END - -#pragma pop_macro("new") -_STL_RESTORE_CLANG_WARNINGS -#pragma warning(pop) -#pragma pack(pop) -#endif // _STL_COMPILER_PREPROCESSOR -#endif // _HASH_MAP_ diff --git a/stl/inc/hash_set b/stl/inc/hash_set deleted file mode 100644 index 676680998ed..00000000000 --- a/stl/inc/hash_set +++ /dev/null @@ -1,385 +0,0 @@ -// hash_set extension header - -// Copyright (c) Microsoft Corporation. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#ifndef _HASH_SET_ -#define _HASH_SET_ -#include -#if _STL_COMPILER_PREPROCESSOR -#include - -#pragma pack(push, _CRT_PACKING) -#pragma warning(push, _STL_WARNING_LEVEL) -#pragma warning(disable : _STL_DISABLED_WARNINGS) -_STL_DISABLE_CLANG_WARNINGS -#pragma push_macro("new") -#undef new - -#ifndef _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -#error is deprecated and will be REMOVED. Please use . You can define \ -_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS to suppress this error. -#endif // _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS - -namespace stdext { - using _STD allocator; - using _STD swap; - using _STD _Hash; - using _STD _Is_nothrow_swappable; - - template // true if multiple equivalent keys are permitted - class _Hset_traits : public _Tr { // traits required to make _Hash behave like a set - public: - using key_type = _Kty; - using value_type = _Kty; - using _Mutable_value_type = _Kty; - using key_compare = _Tr; - using allocator_type = _Alloc; -#if _HAS_CXX17 - using node_type = - _STD _Node_handle<_STD _List_node::void_pointer>, _Alloc, - _STD _Node_handle_set_base, _Kty>; -#endif // _HAS_CXX17 - - static constexpr bool _Multi = _Mfl; - static constexpr bool _Standard = false; - - template - using _In_place_key_extractor = _STD _In_place_key_extract_set<_Kty, _Args...>; - - using key_equal = _Tr; - - static constexpr bool _Has_transparent_overloads = false; - - _Hset_traits() = default; - - _Hset_traits(const _Tr& _Traits) noexcept(_STD is_nothrow_copy_constructible_v<_Tr>) : _Tr(_Traits) {} - - using value_compare = key_compare; - - _NODISCARD static const _Kty& _Kfn(const value_type& _Val) noexcept { - return _Val; - } - - _NODISCARD float& _Get_max_bucket_size() noexcept { - return _Max_buckets; - } - - _NODISCARD const float& _Get_max_bucket_size() const noexcept { - return _Max_buckets; - } - - void swap(_Hset_traits& _Rhs) noexcept(_Is_nothrow_swappable<_Tr>::value) { - using _STD swap; - swap(static_cast<_Tr&>(*this), static_cast<_Tr&>(_Rhs)); // intentional ADL - _STD swap(_Max_buckets, _Rhs._Max_buckets); - } - - float _Max_buckets = 0.0F; // current maximum bucket size - }; - - template >, class _Alloc = allocator<_Kty>> - class hash_set : public _Hash<_Hset_traits<_Kty, _Tr, _Alloc, false>> { // hash table of key values, unique keys - public: - using _Mybase = _Hash<_Hset_traits<_Kty, _Tr, _Alloc, false>>; - using key_type = _Kty; - using key_compare = _Tr; - using value_compare = typename _Mybase::_Value_compare; - using value_type = typename _Mybase::value_type; - using allocator_type = typename _Mybase::allocator_type; - using size_type = typename _Mybase::size_type; - using difference_type = typename _Mybase::difference_type; - using pointer = typename _Mybase::pointer; - using const_pointer = typename _Mybase::const_pointer; - using reference = value_type&; - using const_reference = const value_type&; - using iterator = typename _Mybase::iterator; - using const_iterator = typename _Mybase::const_iterator; - using _Alnode = typename _Mybase::_Alnode; - using _Alnode_traits = typename _Mybase::_Alnode_traits; -#if _HAS_CXX17 - using insert_return_type = _STD _Insert_return_type; -#endif // _HAS_CXX17 - - hash_set() : _Mybase(key_compare(), allocator_type()) {} - - explicit hash_set(const allocator_type& _Al) : _Mybase(key_compare(), _Al) {} - - hash_set(const hash_set& _Right) - : _Mybase(_Right, _Alnode_traits::select_on_container_copy_construction(_Right._Getal())) {} - - hash_set(const hash_set& _Right, const allocator_type& _Al) : _Mybase(_Right, _Al) {} - - explicit hash_set(const key_compare& _Traits) : _Mybase(_Traits, allocator_type()) {} - - hash_set(const key_compare& _Traits, const allocator_type& _Al) : _Mybase(_Traits, _Al) {} - - template - hash_set(_Iter _First, _Iter _Last) : _Mybase(key_compare(), allocator_type()) { - this->insert(_First, _Last); - } - - template - hash_set(_Iter _First, _Iter _Last, const key_compare& _Traits) : _Mybase(_Traits, allocator_type()) { - this->insert(_First, _Last); - } - - template - hash_set(_Iter _First, _Iter _Last, const key_compare& _Traits, const allocator_type& _Al) - : _Mybase(_Traits, _Al) { - this->insert(_First, _Last); - } - - hash_set& operator=(const hash_set& _Right) { - _Mybase::operator=(_Right); - return *this; - } - - hash_set(hash_set&& _Right) : _Mybase(_STD move(_Right)) {} - - hash_set(hash_set&& _Right, const allocator_type& _Al) : _Mybase(_STD move(_Right), _Al) {} - - hash_set& operator=(hash_set&& _Right) noexcept(noexcept(_Mybase::operator=(_STD move(_Right)))) { - _Mybase::operator=(_STD move(_Right)); - return *this; - } - - void swap(hash_set& _Right) noexcept(noexcept(_Mybase::swap(_Right))) { - _Mybase::swap(_Right); - } - - hash_set(_STD initializer_list _Ilist) : _Mybase(key_compare(), allocator_type()) { - this->insert(_Ilist); - } - - hash_set(_STD initializer_list _Ilist, const key_compare& _Pred) - : _Mybase(_Pred, allocator_type()) { - this->insert(_Ilist); - } - - hash_set(_STD initializer_list _Ilist, const key_compare& _Pred, const allocator_type& _Al) - : _Mybase(_Pred, _Al) { - this->insert(_Ilist); - } - - hash_set& operator=(_STD initializer_list _Ilist) { - this->clear(); - this->insert(_Ilist); - return *this; - } - - using reverse_iterator = _STD reverse_iterator; - using const_reverse_iterator = _STD reverse_iterator; - - _NODISCARD reverse_iterator rbegin() noexcept { - return reverse_iterator(this->end()); - } - - _NODISCARD const_reverse_iterator rbegin() const noexcept { - return const_reverse_iterator(this->end()); - } - - _NODISCARD reverse_iterator rend() noexcept { - return reverse_iterator(this->begin()); - } - - _NODISCARD const_reverse_iterator rend() const noexcept { - return const_reverse_iterator(this->begin()); - } - - _NODISCARD const_reverse_iterator crbegin() const noexcept { - return rbegin(); - } - - _NODISCARD const_reverse_iterator crend() const noexcept { - return rend(); - } - - _NODISCARD key_compare key_comp() const { - return this->_Traitsobj; - } - - _NODISCARD value_compare value_comp() const { - return value_compare(key_comp()); - } - - using _Mybase::_Unchecked_begin; - using _Mybase::_Unchecked_end; - }; - - template - void swap(hash_set<_Kty, _Tr, _Alloc>& _Left, hash_set<_Kty, _Tr, _Alloc>& _Right) - noexcept(noexcept(_Left.swap(_Right))) { - _Left.swap(_Right); - } - - template - _NODISCARD bool operator==(const hash_set<_Kty, _Tr, _Alloc>& _Left, const hash_set<_Kty, _Tr, _Alloc>& _Right) { - return _STD _Hash_equal(_Left, _Right); - } - - template - _NODISCARD bool operator!=(const hash_set<_Kty, _Tr, _Alloc>& _Left, const hash_set<_Kty, _Tr, _Alloc>& _Right) { - return !(_Left == _Right); - } - - template >, class _Alloc = allocator<_Kty>> - class hash_multiset - : public _Hash<_Hset_traits<_Kty, _Tr, _Alloc, true>> { // hash table of key values, non-unique keys - public: - using _Mybase = _Hash<_Hset_traits<_Kty, _Tr, _Alloc, true>>; - using key_type = _Kty; - using key_compare = _Tr; - using value_compare = typename _Mybase::_Value_compare; - using value_type = typename _Mybase::value_type; - using allocator_type = typename _Mybase::allocator_type; - using size_type = typename _Mybase::size_type; - using difference_type = typename _Mybase::difference_type; - using pointer = typename _Mybase::pointer; - using const_pointer = typename _Mybase::const_pointer; - using reference = value_type&; - using const_reference = const value_type&; - using iterator = typename _Mybase::iterator; - using const_iterator = typename _Mybase::const_iterator; - using _Alnode = typename _Mybase::_Alnode; - using _Alnode_traits = typename _Mybase::_Alnode_traits; - - hash_multiset() : _Mybase(key_compare(), allocator_type()) {} - - explicit hash_multiset(const allocator_type& _Al) : _Mybase(key_compare(), _Al) {} - - hash_multiset(const hash_multiset& _Right) - : _Mybase(_Right, _Alnode_traits::select_on_container_copy_construction(_Right._Getal())) {} - - hash_multiset(const hash_multiset& _Right, const allocator_type& _Al) : _Mybase(_Right, _Al) {} - - explicit hash_multiset(const key_compare& _Traits) : _Mybase(_Traits, allocator_type()) {} - - hash_multiset(const key_compare& _Traits, const allocator_type& _Al) : _Mybase(_Traits, _Al) {} - - template - hash_multiset(_Iter _First, _Iter _Last) : _Mybase(key_compare(), allocator_type()) { - this->insert(_First, _Last); - } - - template - hash_multiset(_Iter _First, _Iter _Last, const key_compare& _Traits) : _Mybase(_Traits, allocator_type()) { - this->insert(_First, _Last); - } - - template - hash_multiset(_Iter _First, _Iter _Last, const key_compare& _Traits, const allocator_type& _Al) - : _Mybase(_Traits, _Al) { - this->insert(_First, _Last); - } - - hash_multiset& operator=(const hash_multiset& _Right) { - _Mybase::operator=(_Right); - return *this; - } - - hash_multiset(hash_multiset&& _Right) : _Mybase(_STD move(_Right)) {} - - hash_multiset(hash_multiset&& _Right, const allocator_type& _Al) : _Mybase(_STD move(_Right), _Al) {} - - hash_multiset& operator=(hash_multiset&& _Right) noexcept(noexcept(_Mybase::operator=(_STD move(_Right)))) { - _Mybase::operator=(_STD move(_Right)); - return *this; - } - - void swap(hash_multiset& _Right) noexcept(noexcept(_Mybase::swap(_Right))) { - _Mybase::swap(_Right); - } - - hash_multiset(_STD initializer_list _Ilist) : _Mybase(key_compare(), allocator_type()) { - this->insert(_Ilist); - } - - hash_multiset(_STD initializer_list _Ilist, const key_compare& _Pred) - : _Mybase(_Pred, allocator_type()) { - this->insert(_Ilist); - } - - hash_multiset(_STD initializer_list _Ilist, const key_compare& _Pred, const allocator_type& _Al) - : _Mybase(_Pred, _Al) { - this->insert(_Ilist); - } - - hash_multiset& operator=(_STD initializer_list _Ilist) { - this->clear(); - this->insert(_Ilist); - return *this; - } - - using reverse_iterator = _STD reverse_iterator; - using const_reverse_iterator = _STD reverse_iterator; - - _NODISCARD reverse_iterator rbegin() noexcept { - return reverse_iterator(this->end()); - } - - _NODISCARD const_reverse_iterator rbegin() const noexcept { - return const_reverse_iterator(this->end()); - } - - _NODISCARD reverse_iterator rend() noexcept { - return reverse_iterator(this->begin()); - } - - _NODISCARD const_reverse_iterator rend() const noexcept { - return const_reverse_iterator(this->begin()); - } - - _NODISCARD const_reverse_iterator crbegin() const noexcept { - return rbegin(); - } - - _NODISCARD const_reverse_iterator crend() const noexcept { - return rend(); - } - - _NODISCARD key_compare key_comp() const { - return this->_Traitsobj; - } - - _NODISCARD value_compare value_comp() const { - return value_compare(key_comp()); - } - - using _Mybase::_Unchecked_begin; - using _Mybase::_Unchecked_end; - }; - - template - void swap(hash_multiset<_Kty, _Tr, _Alloc>& _Left, hash_multiset<_Kty, _Tr, _Alloc>& _Right) - noexcept(noexcept(_Left.swap(_Right))) { - _Left.swap(_Right); - } - - template - _NODISCARD bool operator==( - const hash_multiset<_Kty, _Tr, _Alloc>& _Left, const hash_multiset<_Kty, _Tr, _Alloc>& _Right) { - return _STD _Hash_equal(_Left, _Right); - } - - template - _NODISCARD bool operator!=( - const hash_multiset<_Kty, _Tr, _Alloc>& _Left, const hash_multiset<_Kty, _Tr, _Alloc>& _Right) { - return !(_Left == _Right); - } -} // namespace stdext - -_STD_BEGIN -using _STDEXT hash_multiset; -using _STDEXT hash_set; -_STD_END - -#pragma pop_macro("new") -_STL_RESTORE_CLANG_WARNINGS -#pragma warning(pop) -#pragma pack(pop) -#endif // _STL_COMPILER_PREPROCESSOR -#endif // _HASH_SET_ diff --git a/stl/inc/header-units.json b/stl/inc/header-units.json index 4d553536b9d..41d0c163b53 100644 --- a/stl/inc/header-units.json +++ b/stl/inc/header-units.json @@ -77,8 +77,6 @@ "functional", "future", "generator", - // "hash_map", // non-Standard, will be removed soon - // "hash_set", // non-Standard, will be removed soon "initializer_list", "iomanip", "ios", diff --git a/stl/inc/unordered_map b/stl/inc/unordered_map index b7f4891cf82..c0e13dcf2b5 100644 --- a/stl/inc/unordered_map +++ b/stl/inc/unordered_map @@ -38,8 +38,7 @@ public: _Node_handle_map_base, _Kty, _Ty>; #endif // _HAS_CXX17 - static constexpr bool _Multi = _Mfl; - static constexpr bool _Standard = true; + static constexpr bool _Multi = _Mfl; template using _In_place_key_extractor = _In_place_key_extract_map<_Kty, _Args...>; @@ -48,8 +47,6 @@ public: explicit _Umap_traits(const _Tr& _Traits) noexcept(is_nothrow_copy_constructible_v<_Tr>) : _Tr(_Traits) {} - using value_compare = void; // TRANSITION, remove when _Standard becomes unconditionally true - template static const _Kty& _Kfn(const pair<_Ty1, _Ty2>& _Val) noexcept { // extract key from element value return _Val.first; diff --git a/stl/inc/unordered_set b/stl/inc/unordered_set index 0f41d148e97..355c5a93ac0 100644 --- a/stl/inc/unordered_set +++ b/stl/inc/unordered_set @@ -37,8 +37,7 @@ public: _Node_handle_set_base, _Kty>; #endif // _HAS_CXX17 - static constexpr bool _Multi = _Mfl; - static constexpr bool _Standard = true; + static constexpr bool _Multi = _Mfl; template using _In_place_key_extractor = _In_place_key_extract_set<_Kty, _Args...>; @@ -47,8 +46,6 @@ public: explicit _Uset_traits(const _Tr& _Traits) noexcept(is_nothrow_copy_constructible_v<_Tr>) : _Tr(_Traits) {} - using value_compare = void; // TRANSITION, remove when _Standard becomes unconditionally true - static const _Kty& _Kfn(const value_type& _Val) noexcept { return _Val; } diff --git a/stl/inc/xhash b/stl/inc/xhash index 4acd8622e13..65cbb0a92df 100644 --- a/stl/inc/xhash +++ b/stl/inc/xhash @@ -13,11 +13,11 @@ #include #include -#ifdef _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS +#ifdef _LEGACY_CODE_ASSUMES_XHASH_INCLUDES_XSTRING #include #include #include -#endif // _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS +#endif // _LEGACY_CODE_ASSUMES_XHASH_INCLUDES_XSTRING #if _HAS_CXX17 #include @@ -30,68 +30,6 @@ _STL_DISABLE_CLANG_WARNINGS #pragma push_macro("new") #undef new -#ifdef _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -_STDEXT_BEGIN -template -_NODISCARD size_t hash_value(const _Kty& _Keyval) noexcept { - if constexpr (_STD is_pointer_v<_Kty> || _STD is_null_pointer_v<_Kty>) { - return reinterpret_cast(_Keyval) ^ 0xdeadbeefu; - } else { - return static_cast(_Keyval) ^ 0xdeadbeefu; - } -} - -template -_NODISCARD size_t hash_value(const _STD basic_string<_Elem, _Traits, _Alloc>& _Str) noexcept { - return _STD _Hash_array_representation(_Str.c_str(), _Str.size()); -} - -_NODISCARD inline size_t hash_value(_In_z_ const char* _Str) noexcept { - return _STD _Hash_array_representation(_Str, _CSTD strlen(_Str)); -} - -_NODISCARD inline size_t hash_value(_In_z_ const wchar_t* _Str) noexcept { - return _STD _Hash_array_representation(_Str, _CSTD wcslen(_Str)); -} - -template > -class hash_compare { // traits class for hash containers -public: - enum { // parameters for hash table - bucket_size = 1 // 0 < bucket_size - }; - - hash_compare() = default; - hash_compare(const _Pr& _Pred) noexcept(_STD is_nothrow_copy_constructible_v<_Pr>) : comp(_Pred) {} - - _NODISCARD size_t operator()(const _Kty& _Keyval) const noexcept(noexcept(hash_value(_Keyval))) { - long _Quot = static_cast(hash_value(_Keyval) & LONG_MAX); // TRANSITION, ADL? - ldiv_t _Qrem = _CSTD ldiv(_Quot, 127773); - - _Qrem.rem = 16807 * _Qrem.rem - 2836 * _Qrem.quot; - if (_Qrem.rem < 0) { - _Qrem.rem += LONG_MAX; - } - - return static_cast(_Qrem.rem); - } - - _NODISCARD bool operator()(const _Kty& _Keyval1, const _Kty& _Keyval2) const - noexcept(noexcept(comp(_Keyval1, _Keyval2))) { - // test if _Keyval1 ordered before _Keyval2 - return comp(_Keyval1, _Keyval2); - } - - _Pr comp{}; // the comparator object -}; -_STDEXT_END - -_STD_BEGIN -using stdext::hash_compare; // Non-Standard, for legacy source compatibility -_STD_END - -#endif // _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS - _STD_BEGIN template struct _Uhash_choose_transparency { @@ -332,9 +270,7 @@ protected: using _Node = typename _Mylist::_Node; using _Nodeptr = typename _Mylist::_Nodeptr; using _Mutable_value_type = typename _Traits::_Mutable_value_type; - - using _Key_compare = typename _Traits::key_compare; - using _Value_compare = typename _Traits::value_compare; + using _Key_compare = typename _Traits::key_compare; public: using key_type = typename _Traits::key_type; @@ -1194,12 +1130,6 @@ private: const _Nodeptr _Bucket_hi = _Vec._Mypair._Myval2._Myfirst[(_Bucket << 1) + 1]._Ptr; for (;;) { if (!_Traitsobj(_Traits::_Kfn(_Where->_Myval), _Keyval)) { - if constexpr (!_Traits::_Standard) { - if (_Traitsobj(_Keyval, _Traits::_Kfn(_Where->_Myval))) { - return _End; - } - } - return _Where; } @@ -1307,12 +1237,6 @@ private: } } - if constexpr (!_Traits::_Standard) { - if (_Traitsobj(_Keyval, _Traits::_Kfn(*_Where))) { - return {_End, _End, 0}; - } - } - const _Unchecked_const_iterator _First = _Where; if constexpr (_Multi) { size_type _Distance = 0; @@ -1591,14 +1515,8 @@ protected: const _Nodeptr _Bucket_lo = _Vec._Mypair._Myval2._Myfirst[_Bucket << 1]._Ptr; for (;;) { - // Search backwards to maintain sorted [_Bucket_lo, _Bucket_hi] when !_Standard + // Search backwards for historical reasons if (!_Traitsobj(_Keyval, _Traits::_Kfn(_Where->_Myval))) { - if constexpr (!_Traits::_Standard) { - if (_Traitsobj(_Traits::_Kfn(_Where->_Myval), _Keyval)) { - return {_Where->_Next, _Nodeptr{}}; - } - } - return {_Where->_Next, _Where}; } @@ -1616,12 +1534,6 @@ protected: // if _Hint points to an element equivalent to _Keyval, returns _Hint; otherwise, // returns _Find_last(_Keyval, _Hashval) if (_Hint != _List._Mypair._Myval2._Myhead && !_Traitsobj(_Traits::_Kfn(_Hint->_Myval), _Keyval)) { - if constexpr (!_Traits::_Standard) { - if (_Traitsobj(_Keyval, _Traits::_Kfn(_Hint->_Myval))) { - return _Find_last(_Keyval, _Hashval); - } - } - return {_Hint->_Next, _Hint}; } @@ -1759,7 +1671,7 @@ protected: const size_type _Bucket = bucket(_Inserted_key); // _Bucket_lo and _Bucket_hi are the *inclusive* range of elements in the bucket, or _Unchecked_end() if - // the bucket is empty; if !_Standard then [_Bucket_lo, _Bucket_hi] is a sorted range. + // the bucket is empty. _Unchecked_iterator& _Bucket_lo = _Vec._Mypair._Myval2._Myfirst[_Bucket << 1]; _Unchecked_iterator& _Bucket_hi = _Vec._Mypair._Myval2._Myfirst[(_Bucket << 1) + 1]; @@ -1785,13 +1697,11 @@ protected: } // The insertion point isn't *_Bucket_hi, so search [_Bucket_lo, _Bucket_hi) for insertion point; we - // go backwards to maintain sortedness when !_Standard. + // go backwards for historical reasons. for (;;) { if (_Bucket_lo == _Insert_before) { // There are no equivalent keys in the bucket, so insert it at the beginning. - // Element can't be already in position here because: - // * (for !_Standard) _Inserted_key < *_Insert_before or - // * (for _Standard) _Inserted_key != *_Insert_before + // Element can't be already in position here because _Inserted_key != *_Insert_before _Mylist::_Scary_val::_Unchecked_splice(_Insert_before._Ptr, _Inserted._Ptr, _Next_inserted._Ptr); _Bucket_lo = _Inserted; break; @@ -1858,21 +1768,7 @@ protected: } } - _Unchecked_const_iterator _Left_stop_at; - if constexpr (_Traits::_Standard) { - _Left_stop_at = _Unchecked_end(); - } else { - // check the first elements for equivalence when !_Standard - if (_Right._Traitsobj(_Keyval, _Traits::_Kfn(*_First2))) { - return {}; - } - - const size_t _LHashval = _Traitsobj(_Keyval); - const size_type _LBucket = _LHashval & _Mask; - const auto _LBucket_hi = _Vec._Mypair._Myval2._Myfirst[(_LBucket << 1) + 1]; - _Left_stop_at = _LBucket_hi; - ++_Left_stop_at; - } + _Unchecked_const_iterator _Left_stop_at = _Unchecked_end(); // trim matching prefixes while (*_First1 == *_First2) { @@ -1967,27 +1863,6 @@ public: _Unchecked_const_iterator _Where = _Vec._Mypair._Myval2._Myfirst[_Bucket << 1]; const _Unchecked_const_iterator _Bucket_hi = _Vec._Mypair._Myval2._Myfirst[(_Bucket << 1) + 1]; if (_Where != _End) { - // check that the bucket is sorted for legacy hash_meow: - if constexpr (!_Traits::_Standard) { - if (_Where != _Bucket_hi) { - auto _SFirst = _Where; - auto _SNext = _Where; - for (;;) { - ++_SNext; - if constexpr (_Traits::_Multi) { - _STL_INTERNAL_CHECK(!_Traitsobj(_Traits::_Kfn(*_SNext), _Traits::_Kfn(*_SFirst))); - } else { - _STL_INTERNAL_CHECK(_Traitsobj(_Traits::_Kfn(*_SFirst), _Traits::_Kfn(*_SNext))); - } - - if (_SNext == _Bucket_hi) { - break; - } - - _SFirst = _SNext; - } - } - } // check that all the elements in the bucket belong in the bucket: for (;;) { ++_Elements; diff --git a/tests/std/tests/Dev10_500860_overloaded_address_of/test.cpp b/tests/std/tests/Dev10_500860_overloaded_address_of/test.cpp index 5718201bf03..3b86c79936b 100644 --- a/tests/std/tests/Dev10_500860_overloaded_address_of/test.cpp +++ b/tests/std/tests/Dev10_500860_overloaded_address_of/test.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #define _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING -#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS #include #include @@ -15,8 +14,6 @@ #include #include #include -#include -#include #include #include #include @@ -87,11 +84,6 @@ namespace Meow { // If it's dragged in via ADL, this op&() will absorb anything. template void operator&(const T&) = delete; - - size_t hash_value(const Evil&) noexcept { - // provide an Evil hash value for stdext::hash_compare - return 0; - } } // namespace Meow using Meow::Evil; @@ -121,11 +113,6 @@ template class std::multimap; template class std::set; template class std::multiset; -template class stdext::hash_map; -template class stdext::hash_multimap; -template class stdext::hash_set; -template class stdext::hash_multiset; - template class std::unordered_map; template class std::unordered_multimap; template class std::unordered_set; diff --git a/tests/std/tests/Dev10_639436_const_map_at/test.cpp b/tests/std/tests/Dev10_639436_const_map_at/test.cpp index 3ba7d04418a..268081a5bad 100644 --- a/tests/std/tests/Dev10_639436_const_map_at/test.cpp +++ b/tests/std/tests/Dev10_639436_const_map_at/test.cpp @@ -1,11 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS - #include #include -#include #include #include @@ -32,6 +29,5 @@ void test_non_const_at() { int main() { test_non_const_at>(); - test_non_const_at>(); test_non_const_at>(); } diff --git a/tests/std/tests/Dev10_766948_insert_ambiguity/test.cpp b/tests/std/tests/Dev10_766948_insert_ambiguity/test.cpp index cea9cf2277c..f02268237ef 100644 --- a/tests/std/tests/Dev10_766948_insert_ambiguity/test.cpp +++ b/tests/std/tests/Dev10_766948_insert_ambiguity/test.cpp @@ -1,12 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS - #include #include -#include -#include #include #include #include @@ -145,11 +141,6 @@ int main() { test_mm>(); test_ms>(); - test_m>(); - test_s>(); - test_mm>(); - test_ms>(); - test_m>(); test_s>(); test_mm>(); diff --git a/tests/std/tests/Dev11_0387701_container_equality/test.cpp b/tests/std/tests/Dev11_0387701_container_equality/test.cpp index ee733eb0e0e..3025dca99cd 100644 --- a/tests/std/tests/Dev11_0387701_container_equality/test.cpp +++ b/tests/std/tests/Dev11_0387701_container_equality/test.cpp @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS - #include #include #include @@ -10,8 +8,6 @@ #include #include #include -#include -#include #include #include #include @@ -103,11 +99,6 @@ int main() { // same sizes, same elements, different orders => should be equal assert_equal(us1, us2); - - stdext::hash_set hs1(us1.begin(), us1.end()); - stdext::hash_set hs2(us2.begin(), us2.end()); - assert_equal(hs1, hs1); - assert_equal(hs1, hs2); } { @@ -133,10 +124,6 @@ int main() { // same sizes, different elements => should be non-equal assert_different(us1, us2); - - stdext::hash_set hs1(us1.begin(), us1.end()); - stdext::hash_set hs2(us2.begin(), us2.end()); - assert_different(hs1, hs2); } { @@ -162,10 +149,6 @@ int main() { // different sizes => should be non-equal assert_different(us1, us2); - - stdext::hash_set hs1(us1.begin(), us1.end()); - stdext::hash_set hs2(us2.begin(), us2.end()); - assert_different(hs1, hs2); } @@ -189,11 +172,6 @@ int main() { // same sizes, same elements, different orders => should be equal assert_equal(ums1, ums2); - - stdext::hash_multiset hms1(ums1.begin(), ums1.end()); - stdext::hash_multiset hms2(ums2.begin(), ums2.end()); - assert_equal(hms1, hms1); - assert_equal(hms1, hms2); } { @@ -227,10 +205,6 @@ int main() { // same sizes, different element counts => should be non-equal assert_different(ums1, ums2); - - stdext::hash_multiset hms1(ums1.begin(), ums1.end()); - stdext::hash_multiset hms2(ums2.begin(), ums2.end()); - assert_different(hms1, hms2); } { @@ -252,10 +226,6 @@ int main() { // same sizes, different elements => should be non-equal assert_different(ums1, ums2); - - stdext::hash_multiset hms1(ums1.begin(), ums1.end()); - stdext::hash_multiset hms2(ums2.begin(), ums2.end()); - assert_different(hms1, hms2); } { @@ -277,10 +247,6 @@ int main() { // different sizes => should be non-equal assert_different(ums1, ums2); - - stdext::hash_multiset hms1(ums1.begin(), ums1.end()); - stdext::hash_multiset hms2(ums2.begin(), ums2.end()); - assert_different(hms1, hms2); } @@ -304,11 +270,6 @@ int main() { // same sizes, same elements, different orders => should be equal assert_equal(um1, um2); - - stdext::hash_map hm1(um1.begin(), um1.end()); - stdext::hash_map hm2(um2.begin(), um2.end()); - assert_equal(hm1, hm1); - assert_equal(hm1, hm2); } { @@ -343,12 +304,6 @@ int main() { // same sizes, different keys, same values => should be non-equal assert_different(um2, um3); - - stdext::hash_map hm1(um1.begin(), um1.end()); - stdext::hash_map hm2(um2.begin(), um2.end()); - stdext::hash_map hm3(um3.begin(), um3.end()); - assert_different(hm1, hm2); - assert_different(hm2, hm3); } { @@ -371,11 +326,6 @@ int main() { // different sizes => should be non-equal assert_different(um1, um2); - - stdext::hash_map hm1(um1.begin(), um1.end()); - stdext::hash_map hm2(um2.begin(), um2.end()); - - assert_different(hm1, hm2); } @@ -399,11 +349,6 @@ int main() { // same sizes, same elements, different orders => should be equal assert_equal(umm1, umm2); - - stdext::hash_multimap hmm1(umm1.begin(), umm1.end()); - stdext::hash_multimap hmm2(umm2.begin(), umm2.end()); - assert_equal(hmm1, hmm1); - assert_equal(hmm1, hmm2); } { @@ -437,10 +382,6 @@ int main() { // same sizes, different element counts => should be non-equal assert_different(umm1, umm2); - - stdext::hash_multimap hmm1(umm1.begin(), umm1.end()); - stdext::hash_multimap hmm2(umm2.begin(), umm2.end()); - assert_different(hmm1, hmm2); } { @@ -470,12 +411,6 @@ int main() { // same sizes, different keys, same values => should be non-equal assert_different(umm2, umm3); - - stdext::hash_multimap hmm1(umm1.begin(), umm1.end()); - stdext::hash_multimap hmm2(umm2.begin(), umm2.end()); - stdext::hash_multimap hmm3(umm3.begin(), umm3.end()); - assert_different(hmm1, hmm2); - assert_different(hmm2, hmm3); } { @@ -497,9 +432,5 @@ int main() { // different sizes => should be non-equal assert_different(umm1, umm2); - - stdext::hash_multimap hmm1(umm1.begin(), umm1.end()); - stdext::hash_multimap hmm2(umm2.begin(), umm2.end()); - assert_different(hmm1, hmm2); } } diff --git a/tests/std/tests/P0919R3_heterogeneous_unordered_lookup/test.cpp b/tests/std/tests/P0919R3_heterogeneous_unordered_lookup/test.cpp index 2fc85fe256d..f4d9a0ebd42 100644 --- a/tests/std/tests/P0919R3_heterogeneous_unordered_lookup/test.cpp +++ b/tests/std/tests/P0919R3_heterogeneous_unordered_lookup/test.cpp @@ -1,11 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS #include #include -#include -#include #include #include #include @@ -428,9 +425,6 @@ void assert_P0809() { } int main() { - assert_unique>>(); - assert_unique< - stdext::hash_map>>>(); assert_unique, equal_to<>, test_allocator>>(); assert_unique, equal_to<>, test_allocator>>>(); @@ -443,9 +437,6 @@ int main() { assert_unique>>>(); - assert_multi>>(); - assert_multi>>>(); assert_multi, equal_to<>, test_allocator>>(); assert_multi, equal_to<>, test_allocator>>>(); diff --git a/tests/std/tests/VSO_0000000_instantiate_containers/test.compile.pass.cpp b/tests/std/tests/VSO_0000000_instantiate_containers/test.compile.pass.cpp index c58b172e9ab..cd8fc908e36 100644 --- a/tests/std/tests/VSO_0000000_instantiate_containers/test.compile.pass.cpp +++ b/tests/std/tests/VSO_0000000_instantiate_containers/test.compile.pass.cpp @@ -2,15 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #define _USE_NAMED_IDL_NAMESPACE 1 -#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS #include #include #include #include #include #include -#include -#include #include #include #include @@ -455,46 +452,6 @@ void forward_list_test() { #endif // ^^^ no workaround ^^^ } -// Note about hash*_test: -// hash* containers have construction semantics like trees instead of hashes -// so construct_*tree*_containers_from_iterators_test is correct. - -void hash_map_test() { - hash_map value{}; - hash_baseclass_test(value); - construct_tree_containers_from_iterators_test(value); - swap_test(value); - equality_test(value); -} - -void hash_multimap_test() { - hash_multimap value{}; - hash_baseclass_test(value); - construct_tree_containers_from_iterators_test(value); - insert_associative_direct_test(value); - insert_with_iterator_test(value); - swap_test(value); - equality_test(value); -} - -void hash_set_test() { - hash_set value{}; - hash_baseclass_test(value); - construct_tree_containers_from_iterators_test(value); - insert_with_iterator_test(value); - swap_test(value); - equality_test(value); -} - -void hash_multiset_test() { - hash_multiset value{}; - hash_baseclass_test(value); - construct_tree_containers_from_iterators_test(value); - insert_with_iterator_test(value); - swap_test(value); - equality_test(value); -} - void initializer_list_test() { initializer_list value{}; (void) begin(value); @@ -999,21 +956,3 @@ void complex_test() { STATIC_ASSERT(is_same_v>); STATIC_ASSERT(is_same_v>); } - - -void xhash_test() { - (void) stdext::hash_value(5); - (void) stdext::hash_value(string{"cat"}); - (void) stdext::hash_value(static_cast(nullptr)); - (void) stdext::hash_value(static_cast(nullptr)); - (void) stdext::hash_value(static_cast(nullptr)); - (void) stdext::hash_value(nullptr); - - (void) stdext::hash_compare()(5); - (void) stdext::hash_compare()("Hello"); - (void) stdext::hash_compare()("World"); - (void) stdext::hash_compare()(L"Wello"); - (void) stdext::hash_compare()(L"Horld"); - - // rest of xhash is covered by container tests -} diff --git a/tests/std/tests/VSO_0144294_unordered_map_max_bucket_count/test.cpp b/tests/std/tests/VSO_0144294_unordered_map_max_bucket_count/test.cpp index d66559c6583..f65371ddb5b 100644 --- a/tests/std/tests/VSO_0144294_unordered_map_max_bucket_count/test.cpp +++ b/tests/std/tests/VSO_0144294_unordered_map_max_bucket_count/test.cpp @@ -1,10 +1,7 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS #include -#include -#include #include #include @@ -17,11 +14,7 @@ void check_max_buckets_is_reasonable(const T& val) { int main() { std::unordered_map umap_test; std::unordered_set uset_test; - stdext::hash_map hashmap_test; - stdext::hash_set hashset_test; check_max_buckets_is_reasonable(umap_test); check_max_buckets_is_reasonable(uset_test); - check_max_buckets_is_reasonable(hashmap_test); - check_max_buckets_is_reasonable(hashset_test); } diff --git a/tests/std/tests/VSO_0429900_fast_debug_range_based_for/test.cpp b/tests/std/tests/VSO_0429900_fast_debug_range_based_for/test.cpp index 2524cd51c6c..644b6b2066b 100644 --- a/tests/std/tests/VSO_0429900_fast_debug_range_based_for/test.cpp +++ b/tests/std/tests/VSO_0429900_fast_debug_range_based_for/test.cpp @@ -1,13 +1,10 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS #include #include #include #include -#include -#include #include #include #include @@ -151,15 +148,11 @@ int main() { vb.push_back(false); assert_range_for(vb); - test_case_set_container(); - test_case_set_container(); test_case_set_container(); test_case_set_container(); test_case_set_container(); test_case_set_container(); - test_case_map_container(); - test_case_map_container(); test_case_map_container(); test_case_map_container(); test_case_map_container(); diff --git a/tests/std/tests/include_each_header_alone_matrix.lst b/tests/std/tests/include_each_header_alone_matrix.lst index b642cb11c6c..7521d9ae009 100644 --- a/tests/std/tests/include_each_header_alone_matrix.lst +++ b/tests/std/tests/include_each_header_alone_matrix.lst @@ -118,6 +118,4 @@ PM_CL="/DMEOW_HEADER=ctime" PM_CL="/DMEOW_HEADER=cuchar" PM_CL="/DMEOW_HEADER=cwchar" PM_CL="/DMEOW_HEADER=cwctype" -PM_CL="/DMEOW_HEADER=hash_map /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS" -PM_CL="/DMEOW_HEADER=hash_set /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS" PM_CL="/DMEOW_HEADER=experimental/filesystem /D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING" diff --git a/tests/tr1/test.lst b/tests/tr1/test.lst index ba59c954fb5..1115eb953c6 100644 --- a/tests/tr1/test.lst +++ b/tests/tr1/test.lst @@ -50,8 +50,6 @@ tests\functional8 tests\functional9 tests\future tests\future1 -tests\hash_map -tests\hash_set tests\initializer_list tests\iomanip tests\ios diff --git a/tests/tr1/tests/hash_map/test.cpp b/tests/tr1/tests/hash_map/test.cpp deleted file mode 100644 index de8d282293c..00000000000 --- a/tests/tr1/tests/hash_map/test.cpp +++ /dev/null @@ -1,604 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -// test -#define TEST_NAME "" - -#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS - -#include "tdefs.h" -#include -#include -#include - -void test_hash_map() { // test hash_map - typedef STD less Mypred; - typedef stdext::hash_compare Mycomp; - typedef STD pair Myval; - typedef STD allocator Myal; - typedef STD hash_map Mycont; - - Myval x, xarr[3], xarr2[3]; - for (int i = 0; i < 3; ++i) { // initialize arrays - new (&xarr[i]) Myval((char) ('a' + i), 1 + i); - new (&xarr2[i]) Myval((char) ('d' + i), 4 + i); - } - - Mycont::key_type* p_key = (char*) nullptr; - Mycont::mapped_type* p_mapped = (int*) nullptr; - Mycont::key_compare* p_kcomp = (Mycomp*) nullptr; - Mycont::allocator_type* p_alloc = (Myal*) nullptr; - Mycont::value_type* p_val = (Myval*) nullptr; - Mycont::value_compare* p_vcomp = nullptr; - Mycont::pointer p_ptr = (Myval*) nullptr; - Mycont::const_pointer p_cptr = (const Myval*) nullptr; - Mycont::reference p_ref = x; - Mycont::const_reference p_cref = (const Myval&) x; - Mycont::size_type* p_size = (CSTD size_t*) nullptr; - Mycont::difference_type* p_diff = (CSTD ptrdiff_t*) nullptr; - - p_key = p_key; // to quiet diagnostics - p_mapped = p_mapped; - p_kcomp = p_kcomp; - p_alloc = p_alloc; - p_val = p_val; - p_vcomp = p_vcomp; - p_ptr = p_ptr; - p_cptr = p_cptr; - p_ptr = &p_ref; - p_cptr = &p_cref; - p_size = p_size; - p_diff = p_diff; - - Mycont v0; - Myal al = v0.get_allocator(); - Mypred pred; - Mycont v0a(pred), v0b(pred, al); - CHECK(v0.empty()); - CHECK_INT(v0.size(), 0); - CHECK_INT(v0a.size(), 0); - CHECK(v0a.get_allocator() == al); - CHECK_INT(v0b.size(), 0); - CHECK(v0b.get_allocator() == al); - - Mycont v1(xarr, xarr + 1); // differs from map - CHECK_INT(v1.size(), 1); - CHECK_INT((*v1.begin()).first, 'a'); - - Mycont v2(xarr, xarr + 1, pred); - CHECK_INT(v2.size(), 1); - CHECK_INT((*v2.begin()).first, 'a'); - - Mycont v3(xarr, xarr + 1, pred, al); - CHECK_INT(v3.size(), 1); - CHECK_INT((*v3.begin()).first, 'a'); - - const Mycont v4(xarr, xarr + 1); - CHECK_INT(v4.size(), 1); - CHECK_INT((*v4.begin()).first, 'a'); - v0 = v4; - CHECK_INT(v0.size(), 1); - CHECK_INT((*v0.begin()).first, 'a'); - CHECK(v0.size() <= v0.max_size()); - - STD hash_map* p_cont = &v0; - - p_cont = p_cont; // to quiet diagnostics - - { // check iterator generators - Mycont::iterator p_it(v1.begin()); - Mycont::const_iterator p_cit(v4.begin()); - Mycont::reverse_iterator p_rit(v1.rbegin()); - Mycont::const_reverse_iterator p_crit(v4.rbegin()); - CHECK_INT((*p_it).first, 'a'); - CHECK_INT((*p_it).second, 1); - CHECK_INT((*--(p_it = v1.end())).first, 'a'); - CHECK_INT((*p_cit).first, 'a'); - CHECK_INT((*--(p_cit = v4.end())).first, 'a'); - CHECK_INT((*p_rit).first, 'a'); - CHECK_INT((*p_rit).second, 1); - CHECK_INT((*--(p_rit = v1.rend())).first, 'a'); - CHECK_INT((*p_crit).first, 'a'); - CHECK_INT((*--(p_crit = v4.rend())).first, 'a'); - - Mycont::const_iterator p_it1 = Mycont::const_iterator(); - Mycont::const_iterator p_it2 = Mycont::const_iterator(); - CHECK(p_it1 == p_it2); // check null forward iterator comparisons - } - - { // check const iterators generators - Mycont::const_iterator p_it(v1.cbegin()); - Mycont::const_iterator p_cit(v4.cbegin()); - Mycont::const_reverse_iterator p_rit(v1.crbegin()); - Mycont::const_reverse_iterator p_crit(v4.crbegin()); - CHECK_INT((*p_it).first, 'a'); - CHECK_INT((*p_it).second, 1); - CHECK_INT((*--(p_it = v1.cend())).first, 'a'); - CHECK_INT((*p_cit).first, 'a'); - CHECK_INT((*--(p_cit = v4.cend())).first, 'a'); - CHECK_INT((*p_rit).first, 'a'); - CHECK_INT((*p_rit).second, 1); - CHECK_INT((*--(p_rit = v1.crend())).first, 'a'); - CHECK_INT((*p_crit).first, 'a'); - CHECK_INT((*--(p_crit = v4.crend())).first, 'a'); - - Mycont::const_iterator p_it1 = Mycont::const_iterator(); - Mycont::const_iterator p_it2 = Mycont::const_iterator(); - CHECK(p_it1 == p_it2); // check null forward iterator comparisons - } - - v0.clear(); // differs from hash_multimap - STD pair pib = v0.insert(Myval('d', 4)); - CHECK_INT((*pib.first).first, 'd'); - CHECK(pib.second); - CHECK_INT((*--v0.end()).first, 'd'); - pib = v0.insert(Myval('d', 5)); - CHECK_INT((*pib.first).first, 'd'); - CHECK_INT((*pib.first).second, 4); - CHECK(!pib.second); - CHECK_INT((*v0.insert(v0.begin(), Myval('e', 5))).first, 'e'); - v0.insert(xarr, xarr + 3); - CHECK_INT(v0.size(), 5); - v0.insert(xarr2, xarr2 + 3); - CHECK_INT(v0.size(), 6); - CHECK_INT(v0['c'], 3); - v0.erase(v0.begin()); - CHECK_INT(v0.size(), 5); - v0.erase(v0.begin(), ++v0.begin()); - CHECK_INT(v0.size(), 4); - v0.insert(Myval('y', 99)); - CHECK_INT(v0.erase('x'), 0); - CHECK_INT(v0.erase('y'), 1); - - { // test added C++11 functionality - Mycont v0c(al); - CHECK_INT(v0c.size(), 0); - CHECK(v0c.get_allocator() == al); - - Mycont v1x(xarr, xarr + 3); - CHECK_INT(v1x.at('c'), 3); - Mycont v2x(v1x, al); - CHECK_INT(v2x.at('c'), 3); - } - - v0.clear(); - CHECK(v0.empty()); - v0.swap(v1); - CHECK(!v0.empty()); - CHECK(v1.empty()); - STD swap(v0, v1); - CHECK(v0.empty()); - CHECK(!v1.empty()); - CHECK(v1 == v1); - CHECK(v0 != v1); - - CHECK(v0.key_comp()('a', 'c')); - CHECK(!v0.key_comp()('a', 'a')); - CHECK(v0.value_comp()(Myval('a', 0), Myval('c', 0))); - CHECK(!v0.value_comp()(Myval('a', 0), Myval('a', 1))); - CHECK_INT((*v4.find('a')).first, 'a'); - CHECK_INT(v4.count('x'), 0); - CHECK_INT(v4.count('a'), 1); - - STD pair pcc = v4.equal_range('a'); - CHECK_INT((*pcc.first).first, 'a'); - CHECK_INT((*--pcc.second).first, 'a'); // differs from map - - { // test bucket functions - Mycont v10(xarr, xarr + 3); - Mycont::size_type nbuckets = v10.bucket_count(); - CHECK(0 < nbuckets); - CHECK(nbuckets <= v10.max_bucket_count()); - Mycont::size_type bucket = v10.bucket('b'); - CHECK(bucket < nbuckets); - Mycont::size_type bsize = v10.bucket_size(bucket); - CHECK(0 < bsize); - - Mycont::local_iterator p_lit(v10.begin(bucket)); - CHECK(0 <= STD distance(p_lit, v10.end(bucket))); - Mycont::const_local_iterator p_clit(v10.begin(bucket)); - CHECK(0 <= STD distance(p_clit, Mycont::const_local_iterator(v10.end(bucket)))); - - float mlf = v10.max_load_factor(); - CHECK(v10.load_factor() <= mlf); - v10.max_load_factor(mlf); - CHECK(v10.max_load_factor() == mlf); - v10.rehash(nbuckets); - CHECK_INT(v10.size(), 3); - CHECK_INT(v10.count('a'), 1); - } - - { - Mycont v6; - v6.insert(Myval('a', 1)); - v6.insert(Myval('b', 2)); - Mycont v7(STD move(v6)); - CHECK_INT(v6.size(), 0); - CHECK_INT(v7.size(), 2); - - Mycont v6a; - v6a.insert(Myval('a', 1)); - v6a.insert(Myval('b', 2)); - Mycont v7a(STD move(v6a), al); - CHECK_INT(v6a.size(), 0); - CHECK_INT(v7a.size(), 2); - - Mycont v8; - v8 = STD move(v7); - CHECK_INT(v7.size(), 0); - CHECK_INT(v8.size(), 2); - - typedef STD hash_map Mycont2; - Mycont2 v9; - STD pair pmi0(Movable_int('a'), 1); - v9.insert(STD move(pmi0)); - CHECK_INT(v9.size(), 1); - CHECK_INT(v9.begin()->first.val, 'a'); - - Mycont2 v10; - STD pair pmi1(Movable_int('d'), 4); - v10.insert(STD move(pmi1)); - CHECK_INT(pmi1.first.val, -1); - CHECK_INT(v10.begin()->first.val, 'd'); - - STD pair pmi2(Movable_int('c'), 3); - v10.clear(); - v10.insert(v10.end(), STD move(pmi2)); - CHECK_INT(pmi2.first.val, -1); - CHECK_INT(v10.begin()->first.val, 'c'); - - Movable_int mi3('a'); - v10.clear(); - CHECK_INT(v10[STD move(mi3)], 0); - CHECK_INT(mi3.val, -1); - CHECK_INT(v10.begin()->first.val, 'a'); - - v10.clear(); - v10.emplace_hint(v10.end()); - CHECK_INT(v10.begin()->first.val, 0); - CHECK_INT(v10.begin()->second, 0); - v10.clear(); - v10.emplace_hint(v10.end(), 'b', 2); - CHECK_INT(v10.begin()->first.val, 'b'); - CHECK_INT(v10.begin()->second, 2); - - v10.clear(); - v10.emplace(); - CHECK_INT(v10.begin()->first.val, 0); - CHECK_INT(v10.begin()->second, 0); - v10.clear(); - v10.emplace('b', 2); - CHECK_INT(v10.begin()->first.val, 'b'); - CHECK_INT(v10.begin()->second, 2); - } - - { // check for lvalue stealing - typedef STD hash_map Mycont3; - Mycont3 v11; - STD pair pci1(Copyable_int('d'), 4); - v11.insert(pci1); - CHECK_INT(pci1.first.val, 'd'); - CHECK_INT(v11.begin()->first.val, 'd'); - - STD pair pci2(Copyable_int('c'), 3); - v11.clear(); - v11.insert(v11.end(), pci2); - CHECK_INT(pci2.first.val, 'c'); - CHECK_INT(v11.begin()->first.val, 'c'); - - Mycont3 v12(v11); - CHECK(v11 == v12); - } - - { - STD initializer_list init{xarr[0], xarr[1], xarr[2]}; - Mycont v11(init); - CHECK_INT(v11.size(), 3); - CHECK_INT(v11.find('a')->second, 1); - - Mycont v11a(init, pred, al); - CHECK_INT(v11a.size(), 3); - CHECK_INT(v11a.begin()->first, 'a'); - - v11.clear(); - v11 = init; - CHECK_INT(v11.size(), 3); - CHECK_INT(v11.find('a')->second, 1); - - v11.clear(); - v11.insert(init); - CHECK_INT(v11.size(), 3); - CHECK_INT(v11.find('a')->second, 1); - } -} - -void test_hash_multimap() { // test hash_multimap - typedef STD less Mypred; - typedef stdext::hash_compare Mycomp; - typedef STD pair Myval; - typedef STD allocator Myal; - typedef STD hash_multimap Mycont; - - Myval x, xarr[3], xarr2[3]; - for (int i = 0; i < 3; ++i) { // initialize arrays - new (&xarr[i]) Myval((char) ('a' + i), 1 + i); - new (&xarr2[i]) Myval((char) ('d' + i), 4 + i); - } - - Mycont::key_type* p_key = (char*) nullptr; - Mycont::mapped_type* p_mapped = (int*) nullptr; - Mycont::key_compare* p_kcomp = (Mycomp*) nullptr; - Mycont::allocator_type* p_alloc = (Myal*) nullptr; - Mycont::value_type* p_val = (Myval*) nullptr; - Mycont::value_compare* p_vcomp = nullptr; - Mycont::pointer p_ptr = (Myval*) nullptr; - Mycont::const_pointer p_cptr = (const Myval*) nullptr; - Mycont::reference p_ref = x; - Mycont::const_reference p_cref = (const Myval&) x; - Mycont::size_type* p_size = (CSTD size_t*) nullptr; - Mycont::difference_type* p_diff = (CSTD ptrdiff_t*) nullptr; - - p_key = p_key; // to quiet diagnostics - p_mapped = p_mapped; - p_kcomp = p_kcomp; - p_alloc = p_alloc; - p_val = p_val; - p_vcomp = p_vcomp; - p_ptr = p_ptr; - p_cptr = p_cptr; - p_ptr = &p_ref; - p_cptr = &p_cref; - p_size = p_size; - p_diff = p_diff; - - Mycont v0; - Myal al = v0.get_allocator(); - Mypred pred; - Mycont v0a(pred), v0b(pred, al); - CHECK(v0.empty()); - CHECK_INT(v0.size(), 0); - CHECK_INT(v0a.size(), 0); - CHECK(v0a.get_allocator() == al); - CHECK_INT(v0b.size(), 0); - CHECK(v0b.get_allocator() == al); - - Mycont v1(xarr, xarr + 1); // differs from multimap - CHECK_INT(v1.size(), 1); - CHECK_INT((*v1.begin()).first, 'a'); - - Mycont v2(xarr, xarr + 1, pred); - CHECK_INT(v2.size(), 1); - CHECK_INT((*v2.begin()).first, 'a'); - - Mycont v3(xarr, xarr + 1, pred, al); - CHECK_INT(v3.size(), 1); - CHECK_INT((*v3.begin()).first, 'a'); - - const Mycont v4(xarr, xarr + 1); - CHECK_INT(v4.size(), 1); - CHECK_INT((*v4.begin()).first, 'a'); - v0 = v4; - CHECK_INT(v0.size(), 1); - CHECK_INT((*v0.begin()).first, 'a'); - CHECK(v0.size() <= v0.max_size()); - - STD hash_multimap* p_cont = &v0; - - p_cont = p_cont; // to quiet diagnostics - - { // check iterator generators - Mycont::iterator p_it(v1.begin()); - Mycont::const_iterator p_cit(v4.begin()); - Mycont::reverse_iterator p_rit(v1.rbegin()); - Mycont::const_reverse_iterator p_crit(v4.rbegin()); - CHECK_INT((*p_it).first, 'a'); - CHECK_INT((*p_it).second, 1); - CHECK_INT((*--(p_it = v1.end())).first, 'a'); - CHECK_INT((*p_cit).first, 'a'); - CHECK_INT((*--(p_cit = v4.end())).first, 'a'); - CHECK_INT((*p_rit).first, 'a'); - CHECK_INT((*p_rit).second, 1); - CHECK_INT((*--(p_rit = v1.rend())).first, 'a'); - CHECK_INT((*p_crit).first, 'a'); - CHECK_INT((*--(p_crit = v4.rend())).first, 'a'); - - Mycont::const_iterator p_it1 = Mycont::const_iterator(); - Mycont::const_iterator p_it2 = Mycont::const_iterator(); - CHECK(p_it1 == p_it2); // check null forward iterator comparisons - } - - { // check const iterators generators - Mycont::const_iterator p_it(v1.cbegin()); - Mycont::const_iterator p_cit(v4.cbegin()); - Mycont::const_reverse_iterator p_rit(v1.crbegin()); - Mycont::const_reverse_iterator p_crit(v4.crbegin()); - CHECK_INT((*p_it).first, 'a'); - CHECK_INT((*p_it).second, 1); - CHECK_INT((*--(p_it = v1.cend())).first, 'a'); - CHECK_INT((*p_cit).first, 'a'); - CHECK_INT((*--(p_cit = v4.cend())).first, 'a'); - CHECK_INT((*p_rit).first, 'a'); - CHECK_INT((*p_rit).second, 1); - CHECK_INT((*--(p_rit = v1.crend())).first, 'a'); - CHECK_INT((*p_crit).first, 'a'); - CHECK_INT((*--(p_crit = v4.crend())).first, 'a'); - - Mycont::const_iterator p_it1 = Mycont::const_iterator(); - Mycont::const_iterator p_it2 = Mycont::const_iterator(); - CHECK(p_it1 == p_it2); // check null forward iterator comparisons - } - - v0.clear(); // differs from hash_map - CHECK_INT((*v0.insert(Myval('d', 4))).first, 'd'); - CHECK_INT((*--v0.end()).first, 'd'); - CHECK_INT((*v0.insert(Myval('d', 5))).first, 'd'); - CHECK_INT(v0.size(), 2); - CHECK_INT((*v0.insert(v0.begin(), Myval('e', 5))).first, 'e'); - v0.insert(xarr, xarr + 3); - CHECK_INT(v0.size(), 6); - v0.insert(xarr2, xarr2 + 3); - CHECK_INT(v0.size(), 9); - v0.erase(v0.begin()); - CHECK_INT(v0.size(), 8); - v0.erase(v0.begin(), ++v0.begin()); - CHECK_INT(v0.size(), 7); - v0.insert(Myval('y', 98)); - v0.insert(Myval('y', 99)); - CHECK_INT(v0.erase('x'), 0); - CHECK_INT(v0.erase('y'), 2); - - { // test added C++11 functionality - Mycont v0c(al); - CHECK_INT(v0c.size(), 0); - CHECK(v0c.get_allocator() == al); - } - - v0.clear(); - CHECK(v0.empty()); - v0.swap(v1); - CHECK(!v0.empty()); - CHECK(v1.empty()); - STD swap(v0, v1); - CHECK(v0.empty()); - CHECK(!v1.empty()); - CHECK(v1 == v1); - CHECK(v0 != v1); - - CHECK(v0.key_comp()('a', 'c')); - CHECK(!v0.key_comp()('a', 'a')); - CHECK(v0.value_comp()(Myval('a', 0), Myval('c', 0))); - CHECK(!v0.value_comp()(Myval('a', 0), Myval('a', 1))); - CHECK_INT((*v4.find('a')).first, 'a'); - CHECK_INT(v4.count('x'), 0); - CHECK_INT(v4.count('a'), 1); - - STD pair pcc = v4.equal_range('a'); - CHECK_INT((*pcc.first).first, 'a'); - CHECK_INT((*--pcc.second).first, 'a'); // differs from multimap - - { // test bucket functions - Mycont v10(xarr, xarr + 3); - Mycont::size_type nbuckets = v10.bucket_count(); - CHECK(0 < nbuckets); - CHECK(nbuckets <= v10.max_bucket_count()); - Mycont::size_type bucket = v10.bucket('b'); - CHECK(bucket < nbuckets); - Mycont::size_type bsize = v10.bucket_size(bucket); - CHECK(0 < bsize); - - Mycont::local_iterator p_lit(v10.begin(bucket)); - CHECK(0 <= STD distance(p_lit, v10.end(bucket))); - Mycont::const_local_iterator p_clit(v10.begin(bucket)); - CHECK(0 <= STD distance(p_clit, Mycont::const_local_iterator(v10.end(bucket)))); - - float mlf = v10.max_load_factor(); - CHECK(v10.load_factor() <= mlf); - v10.max_load_factor(mlf); - CHECK(v10.max_load_factor() == mlf); - v10.rehash(nbuckets); - CHECK_INT(v10.size(), 3); - CHECK_INT(v10.count('a'), 1); - } - - { - Mycont v6; - v6.insert(Myval('a', 1)); - v6.insert(Myval('b', 2)); - Mycont v7(STD move(v6)); - CHECK_INT(v6.size(), 0); - CHECK_INT(v7.size(), 2); - - Mycont v6a; - v6a.insert(Myval('a', 1)); - v6a.insert(Myval('b', 2)); - Mycont v7a(STD move(v6a), al); - CHECK_INT(v6a.size(), 0); - CHECK_INT(v7a.size(), 2); - - Mycont v8; - v8 = STD move(v7); - CHECK_INT(v7.size(), 0); - CHECK_INT(v8.size(), 2); - - typedef STD hash_multimap Mycont2; - Mycont2 v9; - STD pair pmi0(Movable_int('a'), 1); - v9.insert(STD move(pmi0)); - CHECK_INT(v9.size(), 1); - CHECK_INT(v9.begin()->first.val, 'a'); - - Mycont2 v10; - STD pair pmi1(Movable_int('d'), 4); - v10.insert(STD move(pmi1)); - CHECK_INT(pmi1.first.val, -1); - CHECK_INT(v10.begin()->first.val, 'd'); - - STD pair pmi2(Movable_int('c'), 3); - v10.clear(); - v10.insert(v10.end(), STD move(pmi2)); - CHECK_INT(pmi2.first.val, -1); - CHECK_INT(v10.begin()->first.val, 'c'); - - v10.clear(); - v10.emplace_hint(v10.end()); - CHECK_INT(v10.begin()->first.val, 0); - CHECK_INT(v10.begin()->second, 0); - v10.clear(); - v10.emplace_hint(v10.end(), 'b', 2); - CHECK_INT(v10.begin()->first.val, 'b'); - CHECK_INT(v10.begin()->second, 2); - - v10.clear(); - v10.emplace(); - CHECK_INT(v10.begin()->first.val, 0); - CHECK_INT(v10.begin()->second, 0); - v10.clear(); - v10.emplace('b', 2); - CHECK_INT(v10.begin()->first.val, 'b'); - CHECK_INT(v10.begin()->second, 2); - } - - { // check for lvalue stealing - typedef STD hash_multimap Mycont3; - Mycont3 v11; - STD pair pci1(Copyable_int('d'), 4); - v11.insert(pci1); - CHECK_INT(pci1.first.val, 'd'); - CHECK_INT(v11.begin()->first.val, 'd'); - - STD pair pci2(Copyable_int('c'), 3); - v11.clear(); - v11.insert(v11.end(), pci2); - CHECK_INT(pci2.first.val, 'c'); - CHECK_INT(v11.begin()->first.val, 'c'); - - Mycont3 v12(v11); - CHECK(v11 == v12); - } - - { - STD initializer_list init{xarr[0], xarr[1], xarr[2]}; - Mycont v11(init); - CHECK_INT(v11.size(), 3); - CHECK_INT(v11.begin()->first, 'a'); - - v11.clear(); - v11 = init; - CHECK_INT(v11.size(), 3); - CHECK_INT(v11.begin()->first, 'a'); - - Mycont v11a(init, pred, al); - CHECK_INT(v11a.size(), 3); - CHECK_INT(v11a.begin()->first, 'a'); - - v11.clear(); - v11.insert(init); - CHECK_INT(v11.size(), 3); - CHECK_INT(v11.begin()->first, 'a'); - } -} - -void test_main() { // test basic workings of hash_map definitions - test_hash_map(); - test_hash_multimap(); -} diff --git a/tests/tr1/tests/hash_set/test.cpp b/tests/tr1/tests/hash_set/test.cpp deleted file mode 100644 index 9cc50eb6ed4..00000000000 --- a/tests/tr1/tests/hash_set/test.cpp +++ /dev/null @@ -1,610 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -// test -#define TEST_NAME "" - -#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS - -#include "tdefs.h" -#include -#include -#include - -void test_hash_set() { // test hash_set - typedef STD allocator Myal; - typedef STD less Mypred; - typedef stdext::hash_compare Mycomp; - typedef STD hash_set Mycont; - char ch = '\0'; - char carr[] = "abc"; - char carr2[] = "def"; - - Mycont::key_type* p_key = (char*) nullptr; - Mycont::key_compare* p_kcomp = (Mycomp*) nullptr; - Mycont::allocator_type* p_alloc = (Myal*) nullptr; - Mycont::value_type* p_val = (char*) nullptr; - Mycont::value_compare* p_vcomp = nullptr; - Mycont::pointer p_ptr = (char*) nullptr; - Mycont::const_pointer p_cptr = (const char*) nullptr; - Mycont::reference p_ref = ch; - Mycont::const_reference p_cref = (const char&) ch; - Mycont::size_type* p_size = (CSTD size_t*) nullptr; - Mycont::difference_type* p_diff = (CSTD ptrdiff_t*) nullptr; - - p_key = p_key; // to quiet diagnostics - p_kcomp = p_kcomp; - p_alloc = p_alloc; - p_val = p_val; - p_vcomp = p_vcomp; - p_ptr = p_ptr; - p_cptr = p_cptr; - p_ptr = &p_ref; - p_cptr = &p_cref; - p_size = p_size; - p_diff = p_diff; - - Mycont v0; - Myal al = v0.get_allocator(); - Mypred pred; - Mycont v0a(pred), v0b(pred, al); - CHECK(v0.empty()); - CHECK_INT(v0.size(), 0); - CHECK_INT(v0a.size(), 0); - CHECK(v0a.get_allocator() == al); - CHECK_INT(v0b.size(), 0); - CHECK(v0b.get_allocator() == al); - - Mycont v1(carr, carr + 1); // differs from set - CHECK_INT(v1.size(), 1); - CHECK_INT(*v1.begin(), 'a'); - - Mycont v2(carr, carr + 1, pred); - CHECK_INT(v2.size(), 1); - CHECK_INT(*v2.begin(), 'a'); - - Mycont v3(carr, carr + 1, pred, al); - CHECK_INT(v3.size(), 1); - CHECK_INT(*v3.begin(), 'a'); - - const Mycont v4(carr, carr + 1); - CHECK_INT(v4.size(), 1); - CHECK_INT(*v4.begin(), 'a'); - v0 = v4; - CHECK_INT(v0.size(), 1); - CHECK_INT(*v0.begin(), 'a'); - CHECK(v0.size() <= v0.max_size()); - - STD hash_set* p_cont = &v0; - - p_cont = p_cont; // to quiet diagnostics - - { // check iterator generators - Mycont::iterator p_it(v1.begin()); - Mycont::const_iterator p_cit(v4.begin()); - Mycont::reverse_iterator p_rit(v1.rbegin()); - Mycont::const_reverse_iterator p_crit(v4.rbegin()); - CHECK_INT(*p_it, 'a'); - CHECK_INT(*--(p_it = v1.end()), 'a'); - CHECK_INT(*p_cit, 'a'); - CHECK_INT(*--(p_cit = v4.end()), 'a'); - CHECK_INT(*p_rit, 'a'); - CHECK_INT(*--(p_rit = v1.rend()), 'a'); - CHECK_INT(*p_crit, 'a'); - CHECK_INT(*--(p_crit = v4.rend()), 'a'); - - Mycont::const_iterator p_it1 = Mycont::const_iterator(); - Mycont::const_iterator p_it2 = Mycont::const_iterator(); - CHECK(p_it1 == p_it2); // check null forward iterator comparisons - } - - { // check const iterators generators - Mycont::const_iterator p_it(v1.cbegin()); - Mycont::const_iterator p_cit(v4.cbegin()); - Mycont::const_reverse_iterator p_rit(v1.crbegin()); - Mycont::const_reverse_iterator p_crit(v4.crbegin()); - CHECK_INT(*p_it, 'a'); - CHECK_INT(*--(p_it = v1.cend()), 'a'); - CHECK_INT(*p_cit, 'a'); - CHECK_INT(*--(p_cit = v4.cend()), 'a'); - CHECK_INT(*p_rit, 'a'); - CHECK_INT(*--(p_rit = v1.crend()), 'a'); - CHECK_INT(*p_crit, 'a'); - CHECK_INT(*--(p_crit = v4.crend()), 'a'); - - Mycont::const_iterator p_it1 = Mycont::const_iterator(); - Mycont::const_iterator p_it2 = Mycont::const_iterator(); - CHECK(p_it1 == p_it2); // check null forward iterator comparisons - } - - v0.clear(); // differs from hash_multiset - STD pair pib = v0.insert('d'); - CHECK_INT(*pib.first, 'd'); - CHECK(pib.second); - CHECK_INT(*--v0.end(), 'd'); - pib = v0.insert('d'); - CHECK_INT(*pib.first, 'd'); - CHECK(!pib.second); - CHECK_INT(*v0.insert(v0.begin(), 'e'), 'e'); - v0.insert(carr, carr + 3); - CHECK_INT(v0.size(), 5); - v0.insert(carr2, carr2 + 3); - CHECK_INT(v0.size(), 6); - v0.erase(v0.begin()); - CHECK_INT(v0.size(), 5); - v0.erase(v0.begin(), ++v0.begin()); - CHECK_INT(v0.size(), 4); - v0.insert('y'); - CHECK_INT(v0.erase('x'), 0); - CHECK_INT(v0.erase('y'), 1); - - { // test added C++11 functionality - Mycont v0c(al); - CHECK_INT(v0c.size(), 0); - CHECK(v0c.get_allocator() == al); - } - - v0.clear(); - CHECK(v0.empty()); - v0.swap(v1); - CHECK(!v0.empty()); - CHECK(v1.empty()); - STD swap(v0, v1); - CHECK(v0.empty()); - CHECK(!v1.empty()); - CHECK(v1 == v1); - CHECK(v0 != v1); - - CHECK(v0.key_comp()('a', 'c')); - CHECK(!v0.key_comp()('a', 'a')); - CHECK(v0.value_comp()('a', 'c')); - CHECK(!v0.value_comp()('a', 'a')); - CHECK_INT(*v4.find('a'), 'a'); - CHECK_INT(v4.count('x'), 0); - CHECK_INT(v4.count('a'), 1); - STD pair pcc = v4.equal_range('a'); - CHECK_INT(*pcc.first, 'a'); - CHECK_INT(*--pcc.second, 'a'); // differs from set - - { // test bucket functions - Mycont v10(carr, carr + 3); - Mycont::size_type nbuckets = v10.bucket_count(); - CHECK(0 < nbuckets); - CHECK(nbuckets <= v10.max_bucket_count()); - Mycont::size_type bucket = v10.bucket('b'); - CHECK(bucket < nbuckets); - Mycont::size_type bsize = v10.bucket_size(bucket); - CHECK(0 < bsize); - - Mycont::local_iterator p_lit(v10.begin(bucket)); - CHECK(0 <= STD distance(p_lit, v10.end(bucket))); - Mycont::const_local_iterator p_clit(v10.begin(bucket)); - CHECK(0 <= STD distance(p_clit, Mycont::const_local_iterator(v10.end(bucket)))); - - float mlf = v10.max_load_factor(); - CHECK(v10.load_factor() <= mlf); - v10.max_load_factor(mlf); - CHECK(v10.max_load_factor() == mlf); - v10.rehash(nbuckets); - CHECK_INT(v10.size(), 3); - CHECK_INT(v10.count('a'), 1); - } - - { - Mycont v6; - v6.insert('a'); - v6.insert('b'); - Mycont v7(STD move(v6)); - CHECK_INT(v6.size(), 0); - CHECK_INT(v7.size(), 2); - - Mycont v6a; - v6a.insert('a'); - v6a.insert('b'); - Mycont v7a(STD move(v6a), al); - CHECK_INT(v6a.size(), 0); - CHECK_INT(v7a.size(), 2); - - Mycont v8; - v8 = STD move(v7); - CHECK_INT(v7.size(), 0); - CHECK_INT(v8.size(), 2); - - typedef STD hash_set Mycont2; - Mycont2 v9; - Movable_int mi0('a'); - v9.insert(STD move(mi0)); - CHECK_INT(v9.size(), 1); - CHECK_INT(v9.begin()->val, 'a'); - - Mycont2 v10; - Movable_int mi1('d'); - v10.clear(); - v10.insert(STD move(mi1)); - CHECK_INT(mi1.val, -1); - CHECK_INT(v10.begin()->val, 'd'); - - Movable_int mi2('c'); - v10.clear(); - v10.insert(v10.end(), STD move(mi2)); - CHECK_INT(mi2.val, -1); - CHECK_INT(v10.begin()->val, 'c'); - - v10.clear(); - v10.emplace_hint(v10.end()); - CHECK_INT(v10.begin()->val, 0); - v10.clear(); - v10.emplace_hint(v10.end(), 2); - CHECK_INT(v10.begin()->val, 2); - v10.clear(); - v10.emplace_hint(v10.end(), 3, 2); - CHECK_INT(v10.begin()->val, 0x32); - v10.clear(); - v10.emplace_hint(v10.end(), 4, 3, 2); - CHECK_INT(v10.begin()->val, 0x432); - v10.clear(); - v10.emplace_hint(v10.end(), 5, 4, 3, 2); - CHECK_INT(v10.begin()->val, 0x5432); - v10.clear(); - v10.emplace_hint(v10.end(), 6, 5, 4, 3, 2); - CHECK_INT(v10.begin()->val, 0x65432); - - v10.clear(); - v10.emplace(); - CHECK_INT(v10.begin()->val, 0); - v10.clear(); - v10.emplace(2); - CHECK_INT(v10.begin()->val, 2); - v10.clear(); - v10.emplace(3, 2); - CHECK_INT(v10.begin()->val, 0x32); - v10.clear(); - v10.emplace(4, 3, 2); - CHECK_INT(v10.begin()->val, 0x432); - v10.clear(); - v10.emplace(5, 4, 3, 2); - CHECK_INT(v10.begin()->val, 0x5432); - v10.clear(); - v10.emplace(6, 5, 4, 3, 2); - CHECK_INT(v10.begin()->val, 0x65432); - } - - { // check for lvalue stealing - typedef STD hash_set Mycont3; - Mycont3 v11; - Copyable_int ci1('d'); - v11.insert(ci1); - CHECK_INT(ci1.val, 'd'); - CHECK_INT(v11.begin()->val, 'd'); - - Copyable_int ci2('c'); - v11.clear(); - v11.insert(v11.end(), ci2); - CHECK_INT(ci2.val, 'c'); - CHECK_INT(v11.begin()->val, 'c'); - - Mycont3 v12(v11); - CHECK(v11 == v12); - } - - { - STD initializer_list init{carr[0], carr[1], carr[2]}; - Mycont v11(init); - CHECK_INT(v11.size(), 3); - CHECK_INT(*v11.find('a'), 'a'); - - v11.clear(); - v11 = init; - CHECK_INT(v11.size(), 3); - CHECK_INT(*v11.find('a'), 'a'); - - Mycont v11a(init, pred, al); - CHECK_INT(v11a.size(), 3); - CHECK_INT(*v11a.find('a'), 'a'); - - v11.clear(); - v11.insert(init); - CHECK_INT(v11.size(), 3); - CHECK_INT(*v11.find('a'), 'a'); - } -} - -void test_hash_multiset() { // test hash_multiset - typedef STD allocator Myal; - typedef STD less Mypred; - typedef stdext::hash_compare Mycomp; - typedef STD hash_multiset Mycont; - char ch = '\0'; - char carr[] = "abc"; - char carr2[] = "def"; - - Mycont::key_type* p_key = (char*) nullptr; - Mycont::key_compare* p_kcomp = (Mycomp*) nullptr; - Mycont::allocator_type* p_alloc = (Myal*) nullptr; - Mycont::value_type* p_val = (char*) nullptr; - Mycont::value_compare* p_vcomp = nullptr; - Mycont::pointer p_ptr = (char*) nullptr; - Mycont::const_pointer p_cptr = (const char*) nullptr; - Mycont::reference p_ref = ch; - Mycont::const_reference p_cref = (const char&) ch; - Mycont::size_type* p_size = (CSTD size_t*) nullptr; - Mycont::difference_type* p_diff = (CSTD ptrdiff_t*) nullptr; - - p_key = p_key; // to quiet diagnostics - p_kcomp = p_kcomp; - p_alloc = p_alloc; - p_val = p_val; - p_vcomp = p_vcomp; - p_ptr = p_ptr; - p_cptr = p_cptr; - p_ptr = &p_ref; - p_cptr = &p_cref; - p_size = p_size; - p_diff = p_diff; - - Mycont v0; - Myal al = v0.get_allocator(); - Mypred pred; - Mycont v0a(pred), v0b(pred, al); - CHECK(v0.empty()); - CHECK_INT(v0.size(), 0); - CHECK_INT(v0a.size(), 0); - CHECK(v0a.get_allocator() == al); - CHECK_INT(v0b.size(), 0); - CHECK(v0b.get_allocator() == al); - - Mycont v1(carr, carr + 1); // differs from multiset - CHECK_INT(v1.size(), 1); - CHECK_INT(*v1.begin(), 'a'); - - Mycont v2(carr, carr + 1, pred); - CHECK_INT(v2.size(), 1); - CHECK_INT(*v2.begin(), 'a'); - - Mycont v3(carr, carr + 1, pred, al); - CHECK_INT(v3.size(), 1); - CHECK_INT(*v3.begin(), 'a'); - - const Mycont v4(carr, carr + 1); - CHECK_INT(v4.size(), 1); - CHECK_INT(*v4.begin(), 'a'); - v0 = v4; - CHECK_INT(v0.size(), 1); - CHECK_INT(*v0.begin(), 'a'); - CHECK(v0.size() <= v0.max_size()); - - STD hash_multiset* p_cont = &v0; - - p_cont = p_cont; // to quiet diagnostics - - { // check iterator generators - Mycont::iterator p_it(v1.begin()); - Mycont::const_iterator p_cit(v4.begin()); - Mycont::reverse_iterator p_rit(v1.rbegin()); - Mycont::const_reverse_iterator p_crit(v4.rbegin()); - CHECK_INT(*p_it, 'a'); - CHECK_INT(*--(p_it = v1.end()), 'a'); - CHECK_INT(*p_cit, 'a'); - CHECK_INT(*--(p_cit = v4.end()), 'a'); - CHECK_INT(*p_rit, 'a'); - CHECK_INT(*--(p_rit = v1.rend()), 'a'); - CHECK_INT(*p_crit, 'a'); - CHECK_INT(*--(p_crit = v4.rend()), 'a'); - - Mycont::const_iterator p_it1 = Mycont::const_iterator(); - Mycont::const_iterator p_it2 = Mycont::const_iterator(); - CHECK(p_it1 == p_it2); // check null forward iterator comparisons - } - - { // check const iterators generators - Mycont::const_iterator p_it(v1.cbegin()); - Mycont::const_iterator p_cit(v4.cbegin()); - Mycont::const_reverse_iterator p_rit(v1.crbegin()); - Mycont::const_reverse_iterator p_crit(v4.crbegin()); - CHECK_INT(*p_it, 'a'); - CHECK_INT(*--(p_it = v1.cend()), 'a'); - CHECK_INT(*p_cit, 'a'); - CHECK_INT(*--(p_cit = v4.cend()), 'a'); - CHECK_INT(*p_rit, 'a'); - CHECK_INT(*--(p_rit = v1.crend()), 'a'); - CHECK_INT(*p_crit, 'a'); - CHECK_INT(*--(p_crit = v4.crend()), 'a'); - - Mycont::const_iterator p_it1 = Mycont::const_iterator(); - Mycont::const_iterator p_it2 = Mycont::const_iterator(); - CHECK(p_it1 == p_it2); // check null forward iterator comparisons - } - - v0.clear(); // differs from hash_set - CHECK_INT(*v0.insert('d'), 'd'); - CHECK_INT(*--v0.end(), 'd'); - CHECK_INT(*v0.insert('d'), 'd'); - CHECK_INT(v0.size(), 2); - CHECK_INT(*v0.insert(v0.begin(), 'e'), 'e'); - v0.insert(carr, carr + 3); - CHECK_INT(v0.size(), 6); - v0.insert(carr2, carr2 + 3); - CHECK_INT(v0.size(), 9); - v0.erase(v0.begin()); - CHECK_INT(v0.size(), 8); - v0.erase(v0.begin(), ++v0.begin()); - CHECK_INT(v0.size(), 7); - v0.insert('y'); - v0.insert('y'); - CHECK_INT(v0.erase('x'), 0); - CHECK_INT(v0.erase('y'), 2); - - { // test added C++11 functionality - Mycont v0c(al); - CHECK_INT(v0c.size(), 0); - CHECK(v0c.get_allocator() == al); - } - - v0.clear(); - CHECK(v0.empty()); - v0.swap(v1); - CHECK(!v0.empty()); - CHECK(v1.empty()); - STD swap(v0, v1); - CHECK(v0.empty()); - CHECK(!v1.empty()); - CHECK(v1 == v1); - CHECK(v0 != v1); - - CHECK(v0.key_comp()('a', 'c')); - CHECK(!v0.key_comp()('a', 'a')); - CHECK(v0.value_comp()('a', 'c')); - CHECK(!v0.value_comp()('a', 'a')); - CHECK_INT(*v4.find('a'), 'a'); - CHECK_INT(v4.count('x'), 0); - CHECK_INT(v4.count('a'), 1); - STD pair pcc = v4.equal_range('a'); - CHECK_INT(*pcc.first, 'a'); - CHECK_INT(*--pcc.second, 'a'); // differs from multiset - - { // test bucket functions - Mycont v10(carr, carr + 3); - Mycont::size_type nbuckets = v10.bucket_count(); - CHECK(0 < nbuckets); - CHECK(nbuckets <= v10.max_bucket_count()); - Mycont::size_type bucket = v10.bucket('b'); - CHECK(bucket < nbuckets); - Mycont::size_type bsize = v10.bucket_size(bucket); - CHECK(0 < bsize); - - Mycont::local_iterator p_lit(v10.begin(bucket)); - CHECK(0 <= STD distance(p_lit, v10.end(bucket))); - Mycont::const_local_iterator p_clit(v10.begin(bucket)); - CHECK(0 <= STD distance(p_clit, Mycont::const_local_iterator(v10.end(bucket)))); - - float mlf = v10.max_load_factor(); - CHECK(v10.load_factor() <= mlf); - v10.max_load_factor(mlf); - CHECK(v10.max_load_factor() == mlf); - v10.rehash(nbuckets); - CHECK_INT(v10.size(), 3); - CHECK_INT(v10.count('a'), 1); - } - - { - Mycont v6; - v6.insert('a'); - v6.insert('b'); - Mycont v7(STD move(v6)); - CHECK_INT(v6.size(), 0); - CHECK_INT(v7.size(), 2); - - Mycont v6a; - v6a.insert('a'); - v6a.insert('b'); - Mycont v7a(STD move(v6a), al); - CHECK_INT(v6a.size(), 0); - CHECK_INT(v7a.size(), 2); - - Mycont v8; - v8 = STD move(v7); - CHECK_INT(v7.size(), 0); - CHECK_INT(v8.size(), 2); - - typedef STD hash_multiset Mycont2; - Mycont2 v9; - Movable_int mi0('a'); - v9.insert(STD move(mi0)); - CHECK_INT(v9.size(), 1); - CHECK_INT(v9.begin()->val, 'a'); - - Mycont2 v10; - Movable_int mi1('d'); - v10.insert(STD move(mi1)); - CHECK_INT(mi1.val, -1); - CHECK_INT(v10.begin()->val, 'd'); - - Movable_int mi2('c'); - v10.clear(); - v10.insert(v10.end(), STD move(mi2)); - CHECK_INT(mi2.val, -1); - CHECK_INT(v10.begin()->val, 'c'); - - v10.clear(); - v10.emplace_hint(v10.end()); - CHECK_INT(v10.begin()->val, 0); - v10.clear(); - v10.emplace_hint(v10.end(), 2); - CHECK_INT(v10.begin()->val, 2); - v10.clear(); - v10.emplace_hint(v10.end(), 3, 2); - CHECK_INT(v10.begin()->val, 0x32); - v10.clear(); - v10.emplace_hint(v10.end(), 4, 3, 2); - CHECK_INT(v10.begin()->val, 0x432); - v10.clear(); - v10.emplace_hint(v10.end(), 5, 4, 3, 2); - CHECK_INT(v10.begin()->val, 0x5432); - v10.clear(); - v10.emplace_hint(v10.end(), 6, 5, 4, 3, 2); - CHECK_INT(v10.begin()->val, 0x65432); - - v10.clear(); - v10.emplace(); - CHECK_INT(v10.begin()->val, 0); - v10.clear(); - v10.emplace(2); - CHECK_INT(v10.begin()->val, 2); - v10.clear(); - v10.emplace(3, 2); - CHECK_INT(v10.begin()->val, 0x32); - v10.clear(); - v10.emplace(4, 3, 2); - CHECK_INT(v10.begin()->val, 0x432); - v10.clear(); - v10.emplace(5, 4, 3, 2); - CHECK_INT(v10.begin()->val, 0x5432); - v10.clear(); - v10.emplace(6, 5, 4, 3, 2); - CHECK_INT(v10.begin()->val, 0x65432); - } - - { // check for lvalue stealing - typedef STD hash_multiset Mycont3; - Mycont3 v11; - Copyable_int ci1('d'); - v11.insert(ci1); - CHECK_INT(ci1.val, 'd'); - CHECK_INT(v11.begin()->val, 'd'); - - Copyable_int ci2('c'); - v11.clear(); - v11.insert(v11.end(), ci2); - CHECK_INT(ci2.val, 'c'); - CHECK_INT(v11.begin()->val, 'c'); - - Mycont3 v12(v11); - CHECK(v11 == v12); - } - - { - STD initializer_list init{carr[0], carr[1], carr[2]}; - Mycont v11(init); - CHECK_INT(v11.size(), 3); - CHECK_INT(*v11.find('a'), 'a'); - - v11.clear(); - v11 = init; - CHECK_INT(v11.size(), 3); - CHECK_INT(*v11.find('a'), 'a'); - - v11.clear(); - v11.insert(init); - CHECK_INT(v11.size(), 3); - CHECK_INT(*v11.find('a'), 'a'); - - Mycont v11a(init, pred, al); - CHECK_INT(v11a.size(), 3); - CHECK_INT(*v11a.find('a'), 'a'); - } -} - -void test_main() { // test basic workings of hash_set definitions - test_hash_set(); - test_hash_multiset(); -} diff --git a/tests/tr1/tests/map/test.cpp b/tests/tr1/tests/map/test.cpp index 64ea288a56c..56cb2cfd6a4 100644 --- a/tests/tr1/tests/map/test.cpp +++ b/tests/tr1/tests/map/test.cpp @@ -80,7 +80,7 @@ void test_map() { // test map CHECK_INT(v0b.size(), 0); CHECK(v0b.get_allocator() == al); - Mycont v1(xarr, xarr + 3); // differs from hash_map + Mycont v1(xarr, xarr + 3); CHECK_INT(v1.size(), 3); CHECK_INT((*v1.begin()).first, 'a'); @@ -207,11 +207,11 @@ void test_map() { // test map CHECK_INT(v4.count('x'), 0); CHECK_INT(v4.count('a'), 1); CHECK_INT((*v4.lower_bound('a')).first, 'a'); - CHECK((*v4.upper_bound('a')).first == 'b'); // differs from hash_map + CHECK((*v4.upper_bound('a')).first == 'b'); STD pair pcc = v4.equal_range('a'); CHECK_INT((*pcc.first).first, 'a'); - CHECK_INT((*pcc.second).first, 'b'); // differs from hash_map + CHECK_INT((*pcc.second).first, 'b'); { Mycont v6; @@ -390,7 +390,7 @@ void test_multimap() { // test multimap CHECK_INT(v0b.size(), 0); CHECK(v0b.get_allocator() == al); - Mycont v1(xarr, xarr + 3); // differs from hash_multimap + Mycont v1(xarr, xarr + 3); CHECK_INT(v1.size(), 3); CHECK_INT((*v1.begin()).first, 'a'); @@ -508,11 +508,11 @@ void test_multimap() { // test multimap CHECK_INT(v4.count('x'), 0); CHECK_INT(v4.count('a'), 1); CHECK_INT((*v4.lower_bound('a')).first, 'a'); - CHECK((*v4.upper_bound('a')).first == 'b'); // differs from hash_multimap + CHECK((*v4.upper_bound('a')).first == 'b'); STD pair pcc = v4.equal_range('a'); CHECK_INT((*pcc.first).first, 'a'); - CHECK_INT((*pcc.second).first, 'b'); // differs from hash_multimap + CHECK_INT((*pcc.second).first, 'b'); { Mycont v6; diff --git a/tests/tr1/tests/set/test.cpp b/tests/tr1/tests/set/test.cpp index ea09ff6145b..47562793db3 100644 --- a/tests/tr1/tests/set/test.cpp +++ b/tests/tr1/tests/set/test.cpp @@ -72,7 +72,7 @@ void test_set() { // test set CHECK_INT(v0b.size(), 0); CHECK(v0b.get_allocator() == al); - Mycont v1(carr, carr + 3); // differs from hash_set + Mycont v1(carr, carr + 3); CHECK_INT(v1.size(), 3); CHECK_INT(*v1.begin(), 'a'); @@ -188,10 +188,10 @@ void test_set() { // test set CHECK_INT(v4.count('x'), 0); CHECK_INT(v4.count('a'), 1); CHECK_INT(*v4.lower_bound('a'), 'a'); - CHECK_INT(*v4.upper_bound('a'), 'b'); // differs from hash_set + CHECK_INT(*v4.upper_bound('a'), 'b'); STD pair pcc = v4.equal_range('a'); CHECK_INT(*pcc.first, 'a'); - CHECK_INT(*pcc.second, 'b'); // differs from hash_set + CHECK_INT(*pcc.second, 'b'); { Mycont v6; @@ -350,7 +350,7 @@ void test_multiset() { // test multiset CHECK_INT(v0b.size(), 0); CHECK(v0b.get_allocator() == al); - Mycont v1(carr, carr + 3); // differs from hash_multiset + Mycont v1(carr, carr + 3); CHECK_INT(v1.size(), 3); CHECK_INT(*v1.begin(), 'a'); @@ -464,10 +464,10 @@ void test_multiset() { // test multiset CHECK_INT(v4.count('x'), 0); CHECK_INT(v4.count('a'), 1); CHECK_INT(*v4.lower_bound('a'), 'a'); - CHECK_INT(*v4.upper_bound('a'), 'b'); // differs from hash_multiset + CHECK_INT(*v4.upper_bound('a'), 'b'); STD pair pcc = v4.equal_range('a'); CHECK_INT(*pcc.first, 'a'); - CHECK_INT(*pcc.second, 'b'); // differs from hash_multiset + CHECK_INT(*pcc.second, 'b'); { Mycont v6;