]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
allocator.h (struct __alloc_neq): Add.
authorPaolo Carlini <pcarlini@suse.de>
Thu, 18 Oct 2007 19:31:22 +0000 (19:31 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 18 Oct 2007 19:31:22 +0000 (19:31 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/allocator.h
libstdc++-v3/include/bits/stl_list.h

index 7014fbcdd42adfe4f08b10cb364048e19dab47cc..be967f9c65f2d0b352712daad3439d56ea93cddd 100644 (file)
@@ -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...
index 8699fc83a02854a3217f5ab95b96855e459554a4..8a0d0eec887d3a96cffc7cdf04d7d4dadd185ab5 100644 (file)
@@ -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
index bb8f930e7101b623f1bc7969e7bf3d4aa77c4b15..4de31d814b21d55833a412edd0fcbbd9e1c3a475 100644 (file)
@@ -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"));
       }
     };