Commit 67202da4 by Paolo Carlini Committed by Paolo Carlini

allocator.h (struct __alloc_neq): Add.

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.

From-SVN: r129457
parent 37017f4d
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> 2007-10-18 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/hash_map: To... * include/ext/hash_map: To...
......
...@@ -156,6 +156,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -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 _GLIBCXX_END_NAMESPACE
#endif #endif
...@@ -1272,7 +1272,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -1272,7 +1272,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
void void
_M_check_equal_allocators(list& __x) _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")); __throw_runtime_error(__N("list::_M_check_equal_allocators"));
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment