summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-10-18 19:31:22 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-10-18 19:31:22 +0000
commit941a0a7e3d7a8d3523255de33b25eafeba2793ff (patch)
treeb5579db083d66ba31ff9cb07ee98cce65eca750d
parentb99e33d13d2a45b2beb38d73cd0c70f57c26921c (diff)
downloadgcc-941a0a7e3d7a8d3523255de33b25eafeba2793ff.tar.gz
2007-10-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/allocator.h (struct __alloc_neq): Add. * include/bits/stl_list.h (list<>::_M_check_equal_allocators): Use it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129457 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog5
-rw-r--r--libstdc++-v3/include/bits/allocator.h17
-rw-r--r--libstdc++-v3/include/bits/stl_list.h3
3 files changed, 24 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 7014fbcdd42..be967f9c65f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2007-10-18 Paolo Carlini <pcarlini@suse.de>
+
+ * include/bits/allocator.h (struct __alloc_neq): Add.
+ * include/bits/stl_list.h (list<>::_M_check_equal_allocators): Use it.
+
2007-10-18 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/hash_map: To...
diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h
index 8699fc83a02..8a0d0eec887 100644
--- a/libstdc++-v3/include/bits/allocator.h
+++ b/libstdc++-v3/include/bits/allocator.h
@@ -156,6 +156,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
}
};
+ // Optimize for stateless allocators.
+ template<typename _Alloc, bool = __is_empty(_Alloc)>
+ struct __alloc_neq
+ {
+ static bool
+ _S_do_it(const _Alloc&, const _Alloc&)
+ { return false; }
+ };
+
+ template<typename _Alloc>
+ struct __alloc_neq<_Alloc, false>
+ {
+ static bool
+ _S_do_it(const _Alloc& __one, const _Alloc& __two)
+ { return __one != __two; }
+ };
+
_GLIBCXX_END_NAMESPACE
#endif
diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h
index bb8f930e710..4de31d814b2 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -1272,7 +1272,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
void
_M_check_equal_allocators(list& __x)
{
- if (_M_get_Node_allocator() != __x._M_get_Node_allocator())
+ if (std::__alloc_neq<typename _Base::_Node_alloc_type>::
+ _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()))
__throw_runtime_error(__N("list::_M_check_equal_allocators"));
}
};