This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] const overloads for set and multiset
- To: gcc-patches at gcc dot gnu dot org
- Subject: [v3] const overloads for set and multiset
- From: Phil Edwards <pedwards at disaster dot jaj dot com>
- Date: Mon, 4 Jun 2001 12:37:33 -0400
This brings us into line with the LWG's fixes on const overloads; they
exist in some containers but not others, so they've been added to the
containers which were missing them. Tested with no regressions, applied
to branch and trunk. Fixes libstdc++/3034.
2001-06-04 Phil Edwards <pme@sources.redhat.com>
PR libstdc++/3034
* include/bits/stl_multiset.h (find, lower_bound, upper_bound,
equal_range): Add const overloads as per LWG DR 214.
* include/bits/stl_set.h: Likewise.
Index: include/bits/stl_multiset.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_multiset.h,v
retrieving revision 1.4
diff -u -3 -p -r1.4 stl_multiset.h
--- stl_multiset.h 2001/04/13 09:03:18 1.4
+++ stl_multiset.h 2001/06/04 17:48:29
@@ -151,8 +151,32 @@ public:
// multiset operations:
- iterator find(const key_type& __x) const { return _M_t.find(__x); }
size_type count(const key_type& __x) const { return _M_t.count(__x); }
+
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+//214. set::find() missing const overload
+ iterator find(const key_type& __x) { return _M_t.find(__x); }
+ const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
+ iterator lower_bound(const key_type& __x) {
+ return _M_t.lower_bound(__x);
+ }
+ const_iterator lower_bound(const key_type& __x) const {
+ return _M_t.lower_bound(__x);
+ }
+ iterator upper_bound(const key_type& __x) {
+ return _M_t.upper_bound(__x);
+ }
+ const_iterator upper_bound(const key_type& __x) const {
+ return _M_t.upper_bound(__x);
+ }
+ pair<iterator,iterator> equal_range(const key_type& __x) {
+ return _M_t.equal_range(__x);
+ }
+ pair<const_iterator,const_iterator> equal_range(const key_type& __x) const {
+ return _M_t.equal_range(__x);
+ }
+#else
+ iterator find(const key_type& __x) const { return _M_t.find(__x); }
iterator lower_bound(const key_type& __x) const {
return _M_t.lower_bound(__x);
}
@@ -162,6 +186,7 @@ public:
pair<iterator,iterator> equal_range(const key_type& __x) const {
return _M_t.equal_range(__x);
}
+#endif
template <class _K1, class _C1, class _A1>
friend bool operator== (const multiset<_K1,_C1,_A1>&,
Index: include/bits/stl_set.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_set.h,v
retrieving revision 1.4
diff -u -3 -p -r1.4 stl_set.h
--- stl_set.h 2001/04/13 09:03:18 1.4
+++ stl_set.h 2001/06/04 17:48:29
@@ -148,10 +148,34 @@ public:
// set operations:
- iterator find(const key_type& __x) const { return _M_t.find(__x); }
size_type count(const key_type& __x) const {
return _M_t.find(__x) == _M_t.end() ? 0 : 1;
}
+
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+//214. set::find() missing const overload
+ iterator find(const key_type& __x) { return _M_t.find(__x); }
+ const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
+ iterator lower_bound(const key_type& __x) {
+ return _M_t.lower_bound(__x);
+ }
+ const_iterator lower_bound(const key_type& __x) const {
+ return _M_t.lower_bound(__x);
+ }
+ iterator upper_bound(const key_type& __x) {
+ return _M_t.upper_bound(__x);
+ }
+ const_iterator upper_bound(const key_type& __x) const {
+ return _M_t.upper_bound(__x);
+ }
+ pair<iterator,iterator> equal_range(const key_type& __x) {
+ return _M_t.equal_range(__x);
+ }
+ pair<const_iterator,const_iterator> equal_range(const key_type& __x) const {
+ return _M_t.equal_range(__x);
+ }
+#else
+ iterator find(const key_type& __x) const { return _M_t.find(__x); }
iterator lower_bound(const key_type& __x) const {
return _M_t.lower_bound(__x);
}
@@ -161,6 +185,7 @@ public:
pair<iterator,iterator> equal_range(const key_type& __x) const {
return _M_t.equal_range(__x);
}
+#endif
template <class _K1, class _C1, class _A1>
friend bool operator== (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&);