summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2007-04-03 08:32:31 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2007-04-03 08:32:31 +0000
commitf7e52577137bb5d0e7501475eab47331a41fac67 (patch)
tree289abca05a130c779f1723ddf73de9859252d39f /libstdc++-v3
parent5be527d081efb7c875ac3d1ae4df66c6e9388a81 (diff)
downloadgcc-f7e52577137bb5d0e7501475eab47331a41fac67.tar.gz
re PR libstdc++/31440 (libstdc++-g++-v3 discarded qualifiers)
2007-04-03 Paolo Carlini <pcarlini@suse.de> PR libstdc++/31440 * include/bits/stl_tree.h (_M_lower_bound(_Link_type, _Link_type, const _Key&), _M_upper_bound(_Link_type, _Link_type, const _Key&)): Add. (_M_equal_range(const _Key&) const): Remove. (lower_bound(const key_type&), lower_bound(const key_type&) const, upper_bound(const key_type&), upper_bound(const key_type&) const, equal_range(const key_type&), equal_range(const key_type&) const): Adjust. (find(const _Key&), find(const _Key&) const): Tweak. * testsuite/23_containers/map/operations/31440.cc: New. From-SVN: r123452
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog14
-rw-r--r--libstdc++-v3/include/bits/stl_tree.h123
-rw-r--r--libstdc++-v3/testsuite/23_containers/map/operations/31440.cc61
3 files changed, 172 insertions, 26 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index c59cfcd3091..9a25a519eb1 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,17 @@
+2007-04-03 Paolo Carlini <pcarlini@suse.de>
+
+ PR libstdc++/31440
+ * include/bits/stl_tree.h (_M_lower_bound(_Link_type, _Link_type,
+ const _Key&), _M_upper_bound(_Link_type, _Link_type, const _Key&)):
+ Add.
+ (_M_equal_range(const _Key&) const): Remove.
+ (lower_bound(const key_type&), lower_bound(const key_type&) const,
+ upper_bound(const key_type&), upper_bound(const key_type&) const,
+ equal_range(const key_type&), equal_range(const key_type&) const):
+ Adjust.
+ (find(const _Key&), find(const _Key&) const): Tweak.
+ * testsuite/23_containers/map/operations/31440.cc: New.
+
2007-04-02 Matthew Levine <gcc@severeweblint.org>
Paolo Carlini <pcarlini@suse.de>
diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h
index e80afc808a3..c0ecddc8f52 100644
--- a/libstdc++-v3/include/bits/stl_tree.h
+++ b/libstdc++-v3/include/bits/stl_tree.h
@@ -554,16 +554,21 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_erase(_Link_type __x);
iterator
+ _M_lower_bound(_Link_type __x, _Link_type __y,
+ const _Key& __k);
+
+ const_iterator
_M_lower_bound(_Const_Link_type __x, _Const_Link_type __y,
const _Key& __k) const;
iterator
+ _M_upper_bound(_Link_type __x, _Link_type __y,
+ const _Key& __k);
+
+ const_iterator
_M_upper_bound(_Const_Link_type __x, _Const_Link_type __y,
const _Key& __k) const;
- pair<iterator, iterator>
- _M_equal_range(const _Key& __k) const;
-
public:
// allocation/deallocation
_Rb_tree()
@@ -717,27 +722,25 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
iterator
lower_bound(const key_type& __k)
- { return iterator(_M_lower_bound(_M_begin(), _M_end(), __k)); }
+ { return _M_lower_bound(_M_begin(), _M_end(), __k); }
const_iterator
lower_bound(const key_type& __k) const
- { return const_iterator(_M_lower_bound(_M_begin(), _M_end(), __k)); }
+ { return _M_lower_bound(_M_begin(), _M_end(), __k); }
iterator
upper_bound(const key_type& __k)
- { return iterator(_M_upper_bound(_M_begin(), _M_end(), __k)); }
+ { return _M_upper_bound(_M_begin(), _M_end(), __k); }
const_iterator
upper_bound(const key_type& __k) const
- { return const_iterator(_M_upper_bound(_M_begin(), _M_end(), __k)); }
+ { return _M_upper_bound(_M_begin(), _M_end(), __k); }
pair<iterator, iterator>
- equal_range(const key_type& __k)
- { return pair<iterator, iterator>(_M_equal_range(__k)); }
+ equal_range(const key_type& __k);
pair<const_iterator, const_iterator>
- equal_range(const key_type& __k) const
- { return pair<const_iterator, const_iterator>(_M_equal_range(__k)); }
+ equal_range(const key_type& __k) const;
// Debugging.
bool
@@ -929,7 +932,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
+ _Compare, _Alloc>::iterator
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
+ _M_lower_bound(_Link_type __x, _Link_type __y,
+ const _Key& __k)
+ {
+ while (__x != 0)
+ if (!_M_impl._M_key_compare(_S_key(__x), __k))
+ __y = __x, __x = _S_left(__x);
+ else
+ __x = _S_right(__x);
+ return iterator(__y);
+ }
+
+ template<typename _Key, typename _Val, typename _KeyOfValue,
+ typename _Compare, typename _Alloc>
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
+ _Compare, _Alloc>::const_iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
_M_lower_bound(_Const_Link_type __x, _Const_Link_type __y,
const _Key& __k) const
@@ -939,12 +959,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
- return iterator(const_cast<_Link_type>(__y));
+ return const_iterator(__y);
}
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
+ _Compare, _Alloc>::iterator
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
+ _M_upper_bound(_Link_type __x, _Link_type __y,
+ const _Key& __k)
+ {
+ while (__x != 0)
+ if (_M_impl._M_key_compare(__k, _S_key(__x)))
+ __y = __x, __x = _S_left(__x);
+ else
+ __x = _S_right(__x);
+ return iterator(__y);
+ }
+
+ template<typename _Key, typename _Val, typename _KeyOfValue,
+ typename _Compare, typename _Alloc>
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
+ _Compare, _Alloc>::const_iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
_M_upper_bound(_Const_Link_type __x, _Const_Link_type __y,
const _Key& __k) const
@@ -954,16 +991,48 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
- return iterator(const_cast<_Link_type>(__y));
+ return const_iterator(__y);
}
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
_Compare, _Alloc>::iterator,
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator>
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
+ _Compare, _Alloc>::iterator>
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
+ equal_range(const _Key& __k)
+ {
+ _Link_type __x = _M_begin();
+ _Link_type __y = _M_end();
+ while (__x != 0)
+ {
+ if (_M_impl._M_key_compare(_S_key(__x), __k))
+ __x = _S_right(__x);
+ else if (_M_impl._M_key_compare(__k, _S_key(__x)))
+ __y = __x, __x = _S_left(__x);
+ else
+ {
+ _Link_type __xu(__x), __yu(__y);
+ __y = __x, __x = _S_left(__x);
+ __xu = _S_right(__xu);
+ return pair<iterator,
+ iterator>(_M_lower_bound(__x, __y, __k),
+ _M_upper_bound(__xu, __yu, __k));
+ }
+ }
+ return pair<iterator, iterator>(iterator(__y),
+ iterator(__y));
+ }
+
+ template<typename _Key, typename _Val, typename _KeyOfValue,
+ typename _Compare, typename _Alloc>
+ pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
+ _Compare, _Alloc>::const_iterator,
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
+ _Compare, _Alloc>::const_iterator>
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_equal_range(const _Key& __k) const
+ equal_range(const _Key& __k) const
{
_Const_Link_type __x = _M_begin();
_Const_Link_type __y = _M_end();
@@ -978,12 +1047,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_Const_Link_type __xu(__x), __yu(__y);
__y = __x, __x = _S_left(__x);
__xu = _S_right(__xu);
- return pair<iterator, iterator>(_M_lower_bound(__x, __y, __k),
- _M_upper_bound(__xu, __yu, __k));
+ return pair<const_iterator,
+ const_iterator>(_M_lower_bound(__x, __y, __k),
+ _M_upper_bound(__xu, __yu, __k));
}
}
- return pair<iterator, iterator>(iterator(const_cast<_Link_type>(__y)),
- iterator(const_cast<_Link_type>(__y)));
+ return pair<const_iterator, const_iterator>(const_iterator(__y),
+ const_iterator(__y));
}
template<typename _Key, typename _Val, typename _KeyOfValue,
@@ -1295,11 +1365,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
+ _Compare, _Alloc>::iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
find(const _Key& __k)
{
- iterator __j = iterator(_M_lower_bound(_M_begin(), _M_end(), __k));
+ iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
return (__j == end()
|| _M_impl._M_key_compare(__k,
_S_key(__j._M_node))) ? end() : __j;
@@ -1307,12 +1378,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
+ _Compare, _Alloc>::const_iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
find(const _Key& __k) const
{
- const_iterator __j = const_iterator(_M_lower_bound(_M_begin(),
- _M_end(), __k));
+ const_iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
return (__j == end()
|| _M_impl._M_key_compare(__k,
_S_key(__j._M_node))) ? end() : __j;
diff --git a/libstdc++-v3/testsuite/23_containers/map/operations/31440.cc b/libstdc++-v3/testsuite/23_containers/map/operations/31440.cc
new file mode 100644
index 00000000000..54ca6146e2d
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/map/operations/31440.cc
@@ -0,0 +1,61 @@
+// { dg-do compile }
+
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+//
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <map>
+
+// libstdc++/31440
+struct DagNode
+{ };
+
+class MemoTable
+{
+public:
+ void memoRewrite();
+
+private:
+ struct dagNodeLt;
+ class MemoMap;
+
+ MemoMap* memoMap;
+};
+
+struct MemoTable::dagNodeLt
+{
+ bool operator()(const DagNode*, const DagNode*);
+};
+
+class MemoTable::MemoMap
+: public std::map<DagNode*, DagNode*, MemoTable::dagNodeLt>
+{ };
+
+void
+MemoTable::memoRewrite()
+{
+ memoMap->find(0);
+}