From: François Dumont Date: Sun, 7 Jun 2015 20:45:57 +0000 (+0000) Subject: stl_tree.h (_Rb_tree<>::__is_transparent<>): Move to outer scope and rename to ... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d7b35f22be0a732140022245c766fa323f1a768d;p=gcc.git stl_tree.h (_Rb_tree<>::__is_transparent<>): Move to outer scope and rename to ... 2015-06-07 François Dumont * include/bits/stl_tree.h (_Rb_tree<>::__is_transparent<>): Move to outer scope and rename to ... (std::__hash_is_transparent<>): ... this. * include/debug/stl_map.h (map::find<>, map::lower_bound<>, map::upper_bound<>, map::equal_range<>): New member function templates to perform heterogeneous lookup. * include/debug/stl_multimap.h (multimap::find<>, multimap::lower_bound<>, multimap::upper_bound<>, multimap::equal_range<>): Likewise. * include/debug/stl_multiset.h (multiset::find<>, multiset::lower_bound<>, multiset::upper_bound<>, multiset::equal_range<>): Likewise. * include/debug/stl_set.h (set::find<>, set::lower_bound<>, set::upper_bound<>, set::equal_range<>): Likewise. * include/profile/stl_map.h (map::find<>, map::count<>, map::lower_bound<>, map::upper_bound<>, map::equal_range<>): Likewise. * include/profile/stl_multimap.h (multimap::find<>, multimap::count<>, multimap::lower_bound<>, multimap::upper_bound<>, multimap::equal_range<>): Likewise. * include/profile/stl_multiset.h (multiset::find<>, multiset::count<>, multiset::lower_bound<>, multiset::upper_bound<>, multiset::equal_range<>): Likewise. * include/profile/stl_set.h (set::find<>, set::count<>, set::lower_bound<>, set::upper_bound<>, set::equal_range<>): Likewise. * testsuite/23_containers/map/operations/1.cc: Check const variants. * testsuite/23_containers/multimap/operations/1.cc: Likewise. * testsuite/23_containers/multiset/operations/1.cc: Likewise. * testsuite/23_containers/set/operations/1.cc: Likewise. From-SVN: r224200 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index fe8957637b5..3bdcdad2ab4 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,34 @@ +2015-06-07 François Dumont + + * include/bits/stl_tree.h (_Rb_tree<>::__is_transparent<>): Move to + outer scope and rename to ... + (std::__hash_is_transparent<>): ... this. + * include/debug/stl_map.h (map::find<>, + map::lower_bound<>, map::upper_bound<>, map::equal_range<>): New + member function templates to perform heterogeneous lookup. + * include/debug/stl_multimap.h (multimap::find<>, + multimap::lower_bound<>, multimap::upper_bound<>, + multimap::equal_range<>): Likewise. + * include/debug/stl_multiset.h (multiset::find<>, + multiset::lower_bound<>, multiset::upper_bound<>, + multiset::equal_range<>): Likewise. + * include/debug/stl_set.h (set::find<>, + set::lower_bound<>, set::upper_bound<>, set::equal_range<>): Likewise. + * include/profile/stl_map.h (map::find<>, map::count<>, + map::lower_bound<>, map::upper_bound<>, map::equal_range<>): Likewise. + * include/profile/stl_multimap.h (multimap::find<>, multimap::count<>, + multimap::lower_bound<>, multimap::upper_bound<>, + multimap::equal_range<>): Likewise. + * include/profile/stl_multiset.h (multiset::find<>, multiset::count<>, + multiset::lower_bound<>, multiset::upper_bound<>, + multiset::equal_range<>): Likewise. + * include/profile/stl_set.h (set::find<>, set::count<>, + set::lower_bound<>, set::upper_bound<>, set::equal_range<>): Likewise. + * testsuite/23_containers/map/operations/1.cc: Check const variants. + * testsuite/23_containers/multimap/operations/1.cc: Likewise. + * testsuite/23_containers/multiset/operations/1.cc: Likewise. + * testsuite/23_containers/set/operations/1.cc: Likewise. + 2015-06-05 Jonathan Wakely * doc/xml/manual/status_cxx2017.xml: Update status tables. diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index 240f5228530..0ba15ab2b4b 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -341,6 +341,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z, _Rb_tree_node_base& __header) throw (); +#if __cplusplus > 201103L + template> + struct __has_is_transparent + { }; + + template + struct __has_is_transparent<_Cmp, _SfinaeType, + __void_t> + { typedef void type; }; +#endif template > @@ -1109,16 +1119,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION equal_range(const key_type& __k) const; #if __cplusplus > 201103L - template> - struct __is_transparent { }; - - template - struct - __is_transparent<_Cmp, _Kt, __void_t> - { typedef void type; }; - template::type> + typename _Req = + typename __has_is_transparent<_Compare, _Kt>::type> iterator _M_find_tr(const _Kt& __k) { @@ -1127,7 +1130,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template::type> + typename _Req = + typename __has_is_transparent<_Compare, _Kt>::type> const_iterator _M_find_tr(const _Kt& __k) const { @@ -1138,7 +1142,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template::type> + typename _Req = + typename __has_is_transparent<_Compare, _Kt>::type> size_type _M_count_tr(const _Kt& __k) const { @@ -1147,7 +1152,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template::type> + typename _Req = + typename __has_is_transparent<_Compare, _Kt>::type> iterator _M_lower_bound_tr(const _Kt& __k) { @@ -1156,7 +1162,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template::type> + typename _Req = + typename __has_is_transparent<_Compare, _Kt>::type> const_iterator _M_lower_bound_tr(const _Kt& __k) const { @@ -1174,7 +1181,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template::type> + typename _Req = + typename __has_is_transparent<_Compare, _Kt>::type> iterator _M_upper_bound_tr(const _Kt& __k) { @@ -1183,7 +1191,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template::type> + typename _Req = + typename __has_is_transparent<_Compare, _Kt>::type> const_iterator _M_upper_bound_tr(const _Kt& __k) const { @@ -1201,7 +1210,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template::type> + typename _Req = + typename __has_is_transparent<_Compare, _Kt>::type> pair _M_equal_range_tr(const _Kt& __k) { @@ -1211,7 +1221,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template::type> + typename _Req = + typename __has_is_transparent<_Compare, _Kt>::type> pair _M_equal_range_tr(const _Kt& __k) const { diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h index 53d8ecc6988..688fb99d499 100644 --- a/libstdc++-v3/include/debug/map.h +++ b/libstdc++-v3/include/debug/map.h @@ -412,28 +412,82 @@ namespace __debug find(const key_type& __x) { return iterator(_Base::find(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + find(const _Kt& __x) + { return { _Base::find(__x), this }; } +#endif + const_iterator find(const key_type& __x) const { return const_iterator(_Base::find(__x), this); } +#if __cplusplus > 201103L + template::type> + const_iterator + find(const _Kt& __x) const + { return { _Base::find(__x), this }; } +#endif + using _Base::count; iterator lower_bound(const key_type& __x) { return iterator(_Base::lower_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + lower_bound(const _Kt& __x) + { return { _Base::lower_bound(__x), this }; } +#endif + const_iterator lower_bound(const key_type& __x) const { return const_iterator(_Base::lower_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + const_iterator + lower_bound(const _Kt& __x) const + { return { _Base::lower_bound(__x), this }; } +#endif + iterator upper_bound(const key_type& __x) { return iterator(_Base::upper_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + upper_bound(const _Kt& __x) + { return { _Base::upper_bound(__x), this }; } +#endif + const_iterator upper_bound(const key_type& __x) const { return const_iterator(_Base::upper_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + const_iterator + upper_bound(const _Kt& __x) const + { return { _Base::upper_bound(__x), this }; } +#endif + std::pair equal_range(const key_type& __x) { @@ -443,6 +497,18 @@ namespace __debug iterator(__res.second, this)); } +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + std::pair equal_range(const key_type& __x) const { @@ -452,6 +518,18 @@ namespace __debug const_iterator(__res.second, this)); } +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) const + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } diff --git a/libstdc++-v3/include/debug/multimap.h b/libstdc++-v3/include/debug/multimap.h index 5c7f2a91e88..e2c806131f0 100644 --- a/libstdc++-v3/include/debug/multimap.h +++ b/libstdc++-v3/include/debug/multimap.h @@ -393,28 +393,82 @@ namespace __debug find(const key_type& __x) { return iterator(_Base::find(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + find(const _Kt& __x) + { return { _Base::find(__x), this }; } +#endif + const_iterator find(const key_type& __x) const { return const_iterator(_Base::find(__x), this); } +#if __cplusplus > 201103L + template::type> + const_iterator + find(const _Kt& __x) const + { return { _Base::find(__x), this }; } +#endif + using _Base::count; iterator lower_bound(const key_type& __x) { return iterator(_Base::lower_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + lower_bound(const _Kt& __x) + { return { _Base::lower_bound(__x), this }; } +#endif + const_iterator lower_bound(const key_type& __x) const { return const_iterator(_Base::lower_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + const_iterator + lower_bound(const _Kt& __x) const + { return { _Base::lower_bound(__x), this }; } +#endif + iterator upper_bound(const key_type& __x) { return iterator(_Base::upper_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + upper_bound(const _Kt& __x) + { return { _Base::upper_bound(__x), this }; } +#endif + const_iterator upper_bound(const key_type& __x) const { return const_iterator(_Base::upper_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + const_iterator + upper_bound(const _Kt& __x) const + { return { _Base::upper_bound(__x), this }; } +#endif + std::pair equal_range(const key_type& __x) { @@ -424,6 +478,18 @@ namespace __debug iterator(__res.second, this)); } +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + std::pair equal_range(const key_type& __x) const { @@ -433,6 +499,18 @@ namespace __debug const_iterator(__res.second, this)); } +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) const + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } diff --git a/libstdc++-v3/include/debug/multiset.h b/libstdc++-v3/include/debug/multiset.h index 8dec44e73ea..b4d738f4bec 100644 --- a/libstdc++-v3/include/debug/multiset.h +++ b/libstdc++-v3/include/debug/multiset.h @@ -386,6 +386,22 @@ namespace __debug find(const key_type& __x) const { return const_iterator(_Base::find(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + find(const _Kt& __x) + { return { _Base::find(__x), this }; } + + template::type> + const_iterator + find(const _Kt& __x) const + { return { _Base::find(__x), this }; } +#endif + using _Base::count; iterator @@ -398,6 +414,22 @@ namespace __debug lower_bound(const key_type& __x) const { return const_iterator(_Base::lower_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + lower_bound(const _Kt& __x) + { return { _Base::lower_bound(__x), this }; } + + template::type> + const_iterator + lower_bound(const _Kt& __x) const + { return { _Base::lower_bound(__x), this }; } +#endif + iterator upper_bound(const key_type& __x) { return iterator(_Base::upper_bound(__x), this); } @@ -408,6 +440,22 @@ namespace __debug upper_bound(const key_type& __x) const { return const_iterator(_Base::upper_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + upper_bound(const _Kt& __x) + { return { _Base::upper_bound(__x), this }; } + + template::type> + const_iterator + upper_bound(const _Kt& __x) const + { return { _Base::upper_bound(__x), this }; } +#endif + std::pair equal_range(const key_type& __x) { @@ -428,6 +476,28 @@ namespace __debug const_iterator(__res.second, this)); } +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } + + template::type> + std::pair + equal_range(const _Kt& __x) const + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } diff --git a/libstdc++-v3/include/debug/set.h b/libstdc++-v3/include/debug/set.h index 00d539fa261..c13ee811aaa 100644 --- a/libstdc++-v3/include/debug/set.h +++ b/libstdc++-v3/include/debug/set.h @@ -393,6 +393,22 @@ namespace __debug find(const key_type& __x) const { return const_iterator(_Base::find(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + find(const _Kt& __x) + { return { _Base::find(__x), this }; } + + template::type> + const_iterator + find(const _Kt& __x) const + { return { _Base::find(__x), this }; } +#endif + using _Base::count; iterator @@ -405,6 +421,22 @@ namespace __debug lower_bound(const key_type& __x) const { return const_iterator(_Base::lower_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + lower_bound(const _Kt& __x) + { return { _Base::lower_bound(__x), this }; } + + template::type> + const_iterator + lower_bound(const _Kt& __x) const + { return { _Base::lower_bound(__x), this }; } +#endif + iterator upper_bound(const key_type& __x) { return iterator(_Base::upper_bound(__x), this); } @@ -415,7 +447,23 @@ namespace __debug upper_bound(const key_type& __x) const { return const_iterator(_Base::upper_bound(__x), this); } - std::pair +#if __cplusplus > 201103L + template::type> + iterator + upper_bound(const _Kt& __x) + { return { _Base::upper_bound(__x), this }; } + + template::type> + const_iterator + upper_bound(const _Kt& __x) const + { return { _Base::upper_bound(__x), this }; } +#endif + + std::pair equal_range(const key_type& __x) { std::pair<_Base_iterator, _Base_iterator> __res = @@ -426,15 +474,37 @@ namespace __debug // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload - std::pair + std::pair equal_range(const key_type& __x) const { - std::pair<_Base_iterator, _Base_iterator> __res = + std::pair<_Base_const_iterator, _Base_const_iterator> __res = _Base::equal_range(__x); return std::make_pair(const_iterator(__res.first, this), const_iterator(__res.second, this)); } +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } + + template::type> + std::pair + equal_range(const _Kt& __x) const + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } diff --git a/libstdc++-v3/include/profile/map.h b/libstdc++-v3/include/profile/map.h index 1549d3dbdf1..210b9b478c6 100644 --- a/libstdc++-v3/include/profile/map.h +++ b/libstdc++-v3/include/profile/map.h @@ -429,6 +429,18 @@ namespace __profile return iterator(_Base::find(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + find(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + return { _Base::find(__x), this }; + } +#endif + const_iterator find(const key_type& __x) const { @@ -436,6 +448,18 @@ namespace __profile return const_iterator(_Base::find(__x), this); } +#if __cplusplus > 201103L + template::type> + const_iterator + find(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + return { _Base::find(__x), this }; + } +#endif + size_type count(const key_type& __x) const { @@ -443,6 +467,18 @@ namespace __profile return _Base::count(__x); } +#if __cplusplus > 201103L + template::type> + size_type + count(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + return _Base::count(__x); + } +#endif + iterator lower_bound(const key_type& __x) { @@ -451,6 +487,19 @@ namespace __profile return iterator(_Base::lower_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + lower_bound(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::lower_bound(__x), this }; + } +#endif + const_iterator lower_bound(const key_type& __x) const { @@ -459,6 +508,19 @@ namespace __profile return const_iterator(_Base::lower_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + const_iterator + lower_bound(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::lower_bound(__x), this }; + } +#endif + iterator upper_bound(const key_type& __x) { @@ -467,6 +529,19 @@ namespace __profile return iterator(_Base::upper_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + upper_bound(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::upper_bound(__x), this }; + } +#endif + const_iterator upper_bound(const key_type& __x) const { @@ -475,6 +550,19 @@ namespace __profile return const_iterator(_Base::upper_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + const_iterator + upper_bound(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::upper_bound(__x), this }; + } +#endif + std::pair equal_range(const key_type& __x) { @@ -485,6 +573,19 @@ namespace __profile iterator(__base_ret.second, this)); } +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + std::pair equal_range(const key_type& __x) const { @@ -495,6 +596,19 @@ namespace __profile const_iterator(__base_ret.second, this)); } +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } diff --git a/libstdc++-v3/include/profile/multimap.h b/libstdc++-v3/include/profile/multimap.h index 2ed9fcb13ed..4ec77d79ac6 100644 --- a/libstdc++-v3/include/profile/multimap.h +++ b/libstdc++-v3/include/profile/multimap.h @@ -388,6 +388,18 @@ namespace __profile return iterator(_Base::find(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + find(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + return { _Base::find(__x), this }; + } +#endif + const_iterator find(const key_type& __x) const { @@ -395,6 +407,18 @@ namespace __profile return const_iterator(_Base::find(__x), this); } +#if __cplusplus > 201103L + template::type> + const_iterator + find(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + return { _Base::find(__x), this }; + } +#endif + size_type count(const key_type& __x) const { @@ -402,6 +426,18 @@ namespace __profile return _Base::count(__x); } +#if __cplusplus > 201103L + template::type> + size_type + count(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + return _Base::count(__x); + } +#endif + iterator lower_bound(const key_type& __x) { @@ -410,6 +446,19 @@ namespace __profile return iterator(_Base::lower_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + lower_bound(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::lower_bound(__x), this }; + } +#endif + const_iterator lower_bound(const key_type& __x) const { @@ -418,6 +467,19 @@ namespace __profile return const_iterator(_Base::lower_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + const_iterator + lower_bound(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::lower_bound(__x), this }; + } +#endif + iterator upper_bound(const key_type& __x) { @@ -426,6 +488,19 @@ namespace __profile return iterator(_Base::upper_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + upper_bound(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::upper_bound(__x), this }; + } +#endif + const_iterator upper_bound(const key_type& __x) const { @@ -434,6 +509,19 @@ namespace __profile return const_iterator(_Base::upper_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + const_iterator + upper_bound(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::upper_bound(__x), this }; + } +#endif + std::pair equal_range(const key_type& __x) { @@ -444,6 +532,19 @@ namespace __profile iterator(__base_ret.second, this)); } +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + std::pair equal_range(const key_type& __x) const { @@ -454,6 +555,19 @@ namespace __profile const_iterator(__base_ret.second, this)); } +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } diff --git a/libstdc++-v3/include/profile/multiset.h b/libstdc++-v3/include/profile/multiset.h index f2d2f39253d..b304e5c5194 100644 --- a/libstdc++-v3/include/profile/multiset.h +++ b/libstdc++-v3/include/profile/multiset.h @@ -379,6 +379,18 @@ namespace __profile return _Base::count(__x); } +#if __cplusplus > 201103L + template::type> + size_type + count(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + return _Base::count(__x); + } +#endif + // multiset operations: iterator find(const key_type& __x) @@ -396,6 +408,28 @@ namespace __profile return const_iterator(_Base::find(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + find(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + return { _Base::find(__x), this }; + } + + template::type> + const_iterator + find(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + return { _Base::find(__x), this }; + } +#endif + iterator lower_bound(const key_type& __x) { @@ -413,6 +447,30 @@ namespace __profile return const_iterator(_Base::lower_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + lower_bound(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::lower_bound(__x), this }; + } + + template::type> + const_iterator + lower_bound(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::lower_bound(__x), this }; + } +#endif + iterator upper_bound(const key_type& __x) { @@ -431,6 +489,30 @@ namespace __profile return const_iterator(_Base::upper_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + upper_bound(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::upper_bound(__x), this }; + } + + template::type> + const_iterator + upper_bound(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::upper_bound(__x), this }; + } +#endif + std::pair equal_range(const key_type& __x) { @@ -453,6 +535,30 @@ namespace __profile const_iterator(__base_ret.second, this)); } +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } + + template::type> + std::pair + equal_range(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } diff --git a/libstdc++-v3/include/profile/set.h b/libstdc++-v3/include/profile/set.h index a05d10b7f30..3717fde5261 100644 --- a/libstdc++-v3/include/profile/set.h +++ b/libstdc++-v3/include/profile/set.h @@ -369,6 +369,18 @@ namespace __profile return _Base::count(__x); } +#if __cplusplus > 201103L + template::type> + size_type + count(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + return _Base::count(__x); + } +#endif + // set operations: iterator find(const key_type& __x) @@ -384,6 +396,28 @@ namespace __profile return const_iterator(_Base::find(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + find(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + return { _Base::find(__x), this }; + } + + template::type> + const_iterator + find(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + return { _Base::find(__x), this }; + } +#endif + iterator lower_bound(const key_type& __x) { @@ -400,6 +434,30 @@ namespace __profile return const_iterator(_Base::lower_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + lower_bound(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::lower_bound(__x), this }; + } + + template::type> + const_iterator + lower_bound(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::lower_bound(__x), this }; + } +#endif + iterator upper_bound(const key_type& __x) { @@ -416,6 +474,30 @@ namespace __profile return const_iterator(_Base::upper_bound(__x), this); } +#if __cplusplus > 201103L + template::type> + iterator + upper_bound(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::upper_bound(__x), this }; + } + + template::type> + const_iterator + upper_bound(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + __profcxx_map2umap_invalidate(this->_M_map2umap_info); + return { _Base::upper_bound(__x), this }; + } +#endif + std::pair equal_range(const key_type& __x) { @@ -436,6 +518,30 @@ namespace __profile const_iterator(__base_ret.second, this)); } +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } + + template::type> + std::pair + equal_range(const _Kt& __x) const + { + __profcxx_map2umap_find(this->_M_map2umap_info, this->size()); + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } diff --git a/libstdc++-v3/testsuite/23_containers/map/operations/1.cc b/libstdc++-v3/testsuite/23_containers/map/operations/1.cc index 3a1c6e3bb04..76647f5aa32 100644 --- a/libstdc++-v3/testsuite/23_containers/map/operations/1.cc +++ b/libstdc++-v3/testsuite/23_containers/map/operations/1.cc @@ -29,6 +29,7 @@ void test01() map m0; typedef map::iterator iterator; + typedef map::const_iterator const_iterator; typedef pair insert_return_type; pair pp0; typedef map::value_type value_type; @@ -47,7 +48,7 @@ void test01() VERIFY( *pp0.first == value_type(2, 2) ); VERIFY( *pp0.second == value_type(3, 3) ); VERIFY( pp0.first == irt1.first ); - VERIFY( --pp0.first == irt0.first ); + VERIFY( --pp0.first == irt0.first ); VERIFY( pp0.second == irt2.first ); m0.insert(value_type(3, 4)); @@ -59,7 +60,7 @@ void test01() VERIFY( *pp0.first == value_type(3, 3) ); VERIFY( *pp0.second == value_type(4, 6) ); VERIFY( pp0.first == irt2.first ); - VERIFY( --pp0.first == irt1.first ); + VERIFY( --pp0.first == irt1.first ); VERIFY( pp0.second == irt4.first ); insert_return_type irt5 = m0.insert(value_type(0, 7)); @@ -72,7 +73,7 @@ void test01() VERIFY( *pp0.first == value_type(1, 1) ); VERIFY( *pp0.second == value_type(2, 2) ); VERIFY( pp0.first == irt0.first ); - VERIFY( --pp0.first == irt5.first ); + VERIFY( --pp0.first == irt5.first ); VERIFY( pp0.second == irt1.first ); insert_return_type irt6 = m0.insert(value_type(5, 11)); @@ -83,7 +84,7 @@ void test01() VERIFY( m0.count(5) == 1 ); VERIFY( *pp0.first == value_type(5, 11) ); VERIFY( pp0.first == irt6.first ); - VERIFY( --pp0.first == irt4.first ); + VERIFY( --pp0.first == irt4.first ); VERIFY( pp0.second == m0.end() ); m0.insert(value_type(4, 14)); @@ -91,11 +92,11 @@ void test01() m0.insert(value_type(4, 16)); pp0 = m0.equal_range(4); - VERIFY( m0.count(4) == 1 ); + VERIFY( m0.count(4) == 1 ); VERIFY( *pp0.first == value_type(4, 6) ); - VERIFY( *pp0.second == value_type(5, 11) ); + VERIFY( *pp0.second == value_type(5, 11) ); VERIFY( pp0.first == irt4.first ); - VERIFY( --pp0.first == irt3.first ); + VERIFY( --pp0.first == irt3.first ); VERIFY( pp0.second == irt6.first ); m0.insert(value_type(0, 17)); @@ -103,20 +104,21 @@ void test01() m0.insert(value_type(1, 19)); pp0 = m0.equal_range(0); - VERIFY( m0.count(0) == 1 ); + VERIFY( m0.count(0) == 1 ); VERIFY( *pp0.first == value_type(0, 7) ); - VERIFY( *pp0.second == value_type(1, 1) ); + VERIFY( *pp0.second == value_type(1, 1) ); VERIFY( pp0.first == irt5.first ); VERIFY( pp0.first == m0.begin() ); VERIFY( pp0.second == irt0.first ); - pp0 = m0.equal_range(1); - VERIFY( m0.count(1) == 1 ); - VERIFY( *pp0.first == value_type(1, 1) ); - VERIFY( *pp0.second == value_type(2, 2) ); - VERIFY( pp0.first == irt0.first ); - VERIFY( --pp0.first == irt7.first); - VERIFY( pp0.second == irt1.first ); + const map& m1 = m0; + pair pp1 = m1.equal_range(1); + VERIFY( m1.count(1) == 1 ); + VERIFY( *pp1.first == value_type(1, 1) ); + VERIFY( *pp1.second == value_type(2, 2) ); + VERIFY( pp1.first == irt0.first ); + VERIFY( --pp1.first == irt7.first); + VERIFY( pp1.second == irt1.first ); } int diff --git a/libstdc++-v3/testsuite/23_containers/multimap/operations/1.cc b/libstdc++-v3/testsuite/23_containers/multimap/operations/1.cc index 8edd3c95c63..683da160010 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/operations/1.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/operations/1.cc @@ -29,6 +29,7 @@ void test01() multimap mm0; typedef multimap::iterator iterator; + typedef multimap::const_iterator const_iterator; pair pp0; typedef multimap::value_type value_type; @@ -46,7 +47,7 @@ void test01() VERIFY( *pp0.first == value_type(2, 2) ); VERIFY( *pp0.second == value_type(3, 3) ); VERIFY( pp0.first == iter1 ); - VERIFY( --pp0.first == iter0 ); + VERIFY( --pp0.first == iter0 ); VERIFY( pp0.second == iter2 ); mm0.insert(value_type(3, 4)); @@ -58,7 +59,7 @@ void test01() VERIFY( *pp0.first == value_type(3, 3) ); VERIFY( *pp0.second == value_type(4, 6) ); VERIFY( pp0.first == iter2 ); - VERIFY( --pp0.first == iter1 ); + VERIFY( --pp0.first == iter1 ); VERIFY( pp0.second == iter4 ); iterator iter5 = mm0.insert(value_type(0, 7)); @@ -71,7 +72,7 @@ void test01() VERIFY( *pp0.first == value_type(1, 1) ); VERIFY( *pp0.second == value_type(2, 2) ); VERIFY( pp0.first == iter0 ); - VERIFY( --pp0.first == iter5 ); + VERIFY( --pp0.first == iter5 ); VERIFY( pp0.second == iter1 ); iterator iter6 = mm0.insert(value_type(5, 11)); @@ -82,7 +83,7 @@ void test01() VERIFY( mm0.count(5) == 3 ); VERIFY( *pp0.first == value_type(5, 11) ); VERIFY( pp0.first == iter6 ); - VERIFY( --pp0.first == iter4 ); + VERIFY( --pp0.first == iter4 ); VERIFY( pp0.second == mm0.end() ); mm0.insert(value_type(4, 14)); @@ -90,11 +91,11 @@ void test01() mm0.insert(value_type(4, 16)); pp0 = mm0.equal_range(4); - VERIFY( mm0.count(4) == 4 ); + VERIFY( mm0.count(4) == 4 ); VERIFY( *pp0.first == value_type(4, 6) ); - VERIFY( *pp0.second == value_type(5, 11) ); + VERIFY( *pp0.second == value_type(5, 11) ); VERIFY( pp0.first == iter4 ); - VERIFY( --pp0.first == iter3 ); + VERIFY( --pp0.first == iter3 ); VERIFY( pp0.second == iter6 ); mm0.insert(value_type(0, 17)); @@ -102,20 +103,21 @@ void test01() mm0.insert(value_type(1, 19)); pp0 = mm0.equal_range(0); - VERIFY( mm0.count(0) == 3 ); + VERIFY( mm0.count(0) == 3 ); VERIFY( *pp0.first == value_type(0, 7) ); - VERIFY( *pp0.second == value_type(1, 1) ); + VERIFY( *pp0.second == value_type(1, 1) ); VERIFY( pp0.first == iter5 ); VERIFY( pp0.first == mm0.begin() ); VERIFY( pp0.second == iter0 ); - pp0 = mm0.equal_range(1); - VERIFY( mm0.count(1) == 5 ); - VERIFY( *pp0.first == value_type(1, 1) ); - VERIFY( *pp0.second == value_type(2, 2) ); - VERIFY( pp0.first == iter0 ); - VERIFY( --pp0.first == iter7 ); - VERIFY( pp0.second == iter1 ); + const multimap& mm1 = mm0; + pair pp1 = mm1.equal_range(1); + VERIFY( mm1.count(1) == 5 ); + VERIFY( *pp1.first == value_type(1, 1) ); + VERIFY( *pp1.second == value_type(2, 2) ); + VERIFY( pp1.first == iter0 ); + VERIFY( --pp1.first == iter7 ); + VERIFY( pp1.second == iter1 ); } int diff --git a/libstdc++-v3/testsuite/23_containers/multiset/operations/1.cc b/libstdc++-v3/testsuite/23_containers/multiset/operations/1.cc index 8fbca8b7824..88881164f1d 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/operations/1.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/operations/1.cc @@ -29,6 +29,7 @@ void test01() multiset ms0; typedef multiset::iterator iterator; + typedef multiset::const_iterator const_iterator; pair pp0; pp0 = ms0.equal_range(1); @@ -45,19 +46,19 @@ void test01() VERIFY( *pp0.first == 2 ); VERIFY( *pp0.second == 3 ); VERIFY( pp0.first == iter1 ); - VERIFY( --pp0.first == iter0 ); + VERIFY( --pp0.first == iter0 ); VERIFY( pp0.second == iter2 ); ms0.insert(3); iterator iter3 = ms0.insert(3); iterator iter4 = ms0.insert(4); - + pp0 = ms0.equal_range(3); VERIFY( ms0.count(3) == 3 ); VERIFY( *pp0.first == 3 ); VERIFY( *pp0.second == 4 ); VERIFY( pp0.first == iter2 ); - VERIFY( --pp0.first == iter1 ); + VERIFY( --pp0.first == iter1 ); VERIFY( pp0.second == iter4 ); iterator iter5 = ms0.insert(0); @@ -70,7 +71,7 @@ void test01() VERIFY( *pp0.first == 1 ); VERIFY( *pp0.second == 2 ); VERIFY( pp0.first == iter0 ); - VERIFY( --pp0.first == iter5 ); + VERIFY( --pp0.first == iter5 ); VERIFY( pp0.second == iter1 ); iterator iter6 = ms0.insert(5); @@ -81,7 +82,7 @@ void test01() VERIFY( ms0.count(5) == 3 ); VERIFY( *pp0.first == 5 ); VERIFY( pp0.first == iter6 ); - VERIFY( --pp0.first == iter4 ); + VERIFY( --pp0.first == iter4 ); VERIFY( pp0.second == ms0.end() ); ms0.insert(4); @@ -89,32 +90,33 @@ void test01() ms0.insert(4); pp0 = ms0.equal_range(4); - VERIFY( ms0.count(4) == 4 ); + VERIFY( ms0.count(4) == 4 ); VERIFY( *pp0.first == 4 ); - VERIFY( *pp0.second == 5 ); + VERIFY( *pp0.second == 5 ); VERIFY( pp0.first == iter4 ); - VERIFY( --pp0.first == iter3 ); + VERIFY( --pp0.first == iter3 ); VERIFY( pp0.second == iter6 ); - + ms0.insert(0); iterator iter7 = ms0.insert(0); ms0.insert(1); pp0 = ms0.equal_range(0); - VERIFY( ms0.count(0) == 3 ); + VERIFY( ms0.count(0) == 3 ); VERIFY( *pp0.first == 0 ); - VERIFY( *pp0.second == 1 ); + VERIFY( *pp0.second == 1 ); VERIFY( pp0.first == iter5 ); VERIFY( pp0.first == ms0.begin() ); VERIFY( pp0.second == iter0 ); - pp0 = ms0.equal_range(1); - VERIFY( ms0.count(1) == 5 ); - VERIFY( *pp0.first == 1 ); - VERIFY( *pp0.second == 2 ); - VERIFY( pp0.first == iter0 ); - VERIFY( --pp0.first == iter7 ); - VERIFY( pp0.second == iter1 ); + const multiset& ms1 = ms0; + pair pp1 = ms1.equal_range(1); + VERIFY( ms1.count(1) == 5 ); + VERIFY( *pp1.first == 1 ); + VERIFY( *pp1.second == 2 ); + VERIFY( pp1.first == iter0 ); + VERIFY( --pp1.first == iter7 ); + VERIFY( pp1.second == iter1 ); } int diff --git a/libstdc++-v3/testsuite/23_containers/set/operations/1.cc b/libstdc++-v3/testsuite/23_containers/set/operations/1.cc index 6712b79bff4..e648a8b3a66 100644 --- a/libstdc++-v3/testsuite/23_containers/set/operations/1.cc +++ b/libstdc++-v3/testsuite/23_containers/set/operations/1.cc @@ -29,6 +29,7 @@ void test01() set s0; typedef set::iterator iterator; + typedef set::const_iterator const_iterator; typedef pair insert_return_type; pair pp0; @@ -52,13 +53,13 @@ void test01() s0.insert(3); insert_return_type irt3 = s0.insert(3); insert_return_type irt4 = s0.insert(4); - + pp0 = s0.equal_range(3); VERIFY( s0.count(3) == 1 ); VERIFY( *pp0.first == 3 ); VERIFY( *pp0.second == 4 ); VERIFY( pp0.first == irt2.first ); - VERIFY( --pp0.first == irt1.first ); + VERIFY( --pp0.first == irt1.first ); VERIFY( pp0.second == irt4.first ); insert_return_type irt5 = s0.insert(0); @@ -71,7 +72,7 @@ void test01() VERIFY( *pp0.first == 1 ); VERIFY( *pp0.second == 2 ); VERIFY( pp0.first == irt0.first ); - VERIFY( --pp0.first == irt5.first ); + VERIFY( --pp0.first == irt5.first ); VERIFY( pp0.second == irt1.first ); insert_return_type irt6 = s0.insert(5); @@ -82,7 +83,7 @@ void test01() VERIFY( s0.count(5) == 1 ); VERIFY( *pp0.first == 5 ); VERIFY( pp0.first == irt6.first ); - VERIFY( --pp0.first == irt4.first ); + VERIFY( --pp0.first == irt4.first ); VERIFY( pp0.second == s0.end() ); s0.insert(4); @@ -90,32 +91,33 @@ void test01() s0.insert(4); pp0 = s0.equal_range(4); - VERIFY( s0.count(4) == 1 ); + VERIFY( s0.count(4) == 1 ); VERIFY( *pp0.first == 4 ); - VERIFY( *pp0.second == 5 ); + VERIFY( *pp0.second == 5 ); VERIFY( pp0.first == irt4.first ); - VERIFY( --pp0.first == irt3.first ); + VERIFY( --pp0.first == irt3.first ); VERIFY( pp0.second == irt6.first ); - + s0.insert(0); insert_return_type irt7 = s0.insert(0); s0.insert(1); pp0 = s0.equal_range(0); - VERIFY( s0.count(0) == 1 ); + VERIFY( s0.count(0) == 1 ); VERIFY( *pp0.first == 0 ); - VERIFY( *pp0.second == 1 ); + VERIFY( *pp0.second == 1 ); VERIFY( pp0.first == irt5.first ); VERIFY( pp0.first == s0.begin() ); VERIFY( pp0.second == irt0.first ); - pp0 = s0.equal_range(1); - VERIFY( s0.count(1) == 1 ); - VERIFY( *pp0.first == 1 ); - VERIFY( *pp0.second == 2 ); - VERIFY( pp0.first == irt0.first ); - VERIFY( --pp0.first == irt7.first ); - VERIFY( pp0.second == irt1.first ); + const set& s1 = s0; + pair pp1 = s1.equal_range(1); + VERIFY( s1.count(1) == 1 ); + VERIFY( *pp1.first == 1 ); + VERIFY( *pp1.second == 2 ); + VERIFY( pp1.first == irt0.first ); + VERIFY( --pp1.first == irt7.first ); + VERIFY( pp1.second == irt1.first ); } int