diff options
Diffstat (limited to 'include/map')
-rw-r--r-- | include/map | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/include/map b/include/map index 009e8e2162c5..5c3969acdd28 100644 --- a/include/map +++ b/include/map @@ -159,7 +159,7 @@ public: template<typename K> const_iterator find(const K& x) const; // C++14 template<typename K> - size_type count(const K& x) const; + size_type count(const K& x) const; // C++14 size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); @@ -353,7 +353,7 @@ public: template<typename K> const_iterator find(const K& x) const; // C++14 template<typename K> - size_type count(const K& x) const; + size_type count(const K& x) const; // C++14 size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); @@ -835,11 +835,18 @@ public: typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; _LIBCPP_INLINE_VISIBILITY - explicit map(const key_compare& __comp = key_compare()) + map() _NOEXCEPT_( is_nothrow_default_constructible<allocator_type>::value && is_nothrow_default_constructible<key_compare>::value && is_nothrow_copy_constructible<key_compare>::value) + : __tree_(__vc(key_compare())) {} + + _LIBCPP_INLINE_VISIBILITY + explicit map(const key_compare& __comp) + _NOEXCEPT_( + is_nothrow_default_constructible<allocator_type>::value && + is_nothrow_copy_constructible<key_compare>::value) : __tree_(__vc(__comp)) {} _LIBCPP_INLINE_VISIBILITY @@ -884,10 +891,12 @@ public: #if __cplusplus >= 201103L __tree_ = __m.__tree_; #else - __tree_.clear(); - __tree_.value_comp() = __m.__tree_.value_comp(); - __tree_.__copy_assign_alloc(__m.__tree_); - insert(__m.begin(), __m.end()); + if (this != &__m) { + __tree_.clear(); + __tree_.value_comp() = __m.__tree_.value_comp(); + __tree_.__copy_assign_alloc(__m.__tree_); + insert(__m.begin(), __m.end()); + } #endif return *this; } @@ -1095,6 +1104,12 @@ public: _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_unique(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type + count(const _K2& __k) {return __tree_.__count_unique(__k);} +#endif _LIBCPP_INLINE_VISIBILITY iterator lower_bound(const key_type& __k) {return __tree_.lower_bound(__k);} @@ -1566,11 +1581,18 @@ public: typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; _LIBCPP_INLINE_VISIBILITY - explicit multimap(const key_compare& __comp = key_compare()) + multimap() _NOEXCEPT_( is_nothrow_default_constructible<allocator_type>::value && is_nothrow_default_constructible<key_compare>::value && is_nothrow_copy_constructible<key_compare>::value) + : __tree_(__vc(key_compare())) {} + + _LIBCPP_INLINE_VISIBILITY + explicit multimap(const key_compare& __comp) + _NOEXCEPT_( + is_nothrow_default_constructible<allocator_type>::value && + is_nothrow_copy_constructible<key_compare>::value) : __tree_(__vc(__comp)) {} _LIBCPP_INLINE_VISIBILITY @@ -1616,10 +1638,12 @@ public: #if __cplusplus >= 201103L __tree_ = __m.__tree_; #else - __tree_.clear(); - __tree_.value_comp() = __m.__tree_.value_comp(); - __tree_.__copy_assign_alloc(__m.__tree_); - insert(__m.begin(), __m.end()); + if (this != &__m) { + __tree_.clear(); + __tree_.value_comp() = __m.__tree_.value_comp(); + __tree_.__copy_assign_alloc(__m.__tree_); + insert(__m.begin(), __m.end()); + } #endif return *this; } @@ -1816,6 +1840,12 @@ public: _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_multi(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type + count(const _K2& __k) {return __tree_.__count_multi(__k);} +#endif _LIBCPP_INLINE_VISIBILITY iterator lower_bound(const key_type& __k) {return __tree_.lower_bound(__k);} |