aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/libstdc++-v3/include/bits/stl_tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.4.3/libstdc++-v3/include/bits/stl_tree.h')
-rw-r--r--gcc-4.4.3/libstdc++-v3/include/bits/stl_tree.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/gcc-4.4.3/libstdc++-v3/include/bits/stl_tree.h b/gcc-4.4.3/libstdc++-v3/include/bits/stl_tree.h
index 4f0ad2d8d..e2cc1518d 100644
--- a/gcc-4.4.3/libstdc++-v3/include/bits/stl_tree.h
+++ b/gcc-4.4.3/libstdc++-v3/include/bits/stl_tree.h
@@ -456,22 +456,34 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#if __google_stl_debug_rbtree
template<typename _KeyCompare>
struct _CheckedCompare {
- // Mutable because some clients use non-const operator().
- mutable _KeyCompare _M_key_compare;
+ _KeyCompare _M_key_compare;
_CheckedCompare(): _M_key_compare() { }
_CheckedCompare(const _KeyCompare & __comp): _M_key_compare(__comp) { }
- bool operator()(const _Key& __x, const _Key& __y) const {
- if (_M_key_compare(__x, __x))
+ // Template arg required to avoid duplicating code in the two op()
+ // operators below. User-provided _M_key_compare may not be const,
+ // but needs to be callable from our const op().
+ // See http://b/1731200 for details.
+ template <typename _KeyCompareT>
+ static bool _M_compare_with(_KeyCompareT& __comp, const _Key& __x, const _Key& __y) {
+ if (__comp(__x, __x))
__throw_runtime_error("strict weak ordering: (__x LT __x) != false");
- if (_M_key_compare(__y, __y))
+ if (__comp(__y, __y))
__throw_runtime_error("strict weak ordering: (__y LT __y) != false");
- bool lt = _M_key_compare(__x, __y);
- if (lt && _M_key_compare(__y, __x))
+ bool lt = __comp(__x, __y);
+ if (lt && __comp(__y, __x))
__throw_runtime_error("strict weak ordering: ((__x LT __y) && (__y LT __x)) != false");
return lt;
}
+ bool operator()(const _Key& __x, const _Key& __y) const {
+ return _M_compare_with(_M_key_compare, __x, __y);
+ }
+
+ bool operator()(const _Key& __x, const _Key& __y) {
+ return _M_compare_with(_M_key_compare, __x, __y);
+ }
+
operator _KeyCompare() const { return _M_key_compare; }
};