Boost logo

Boost-Commit :

From: xushiweizh_at_[hidden]
Date: 2008-07-19 05:29:40


Author: xushiwei
Date: 2008-07-19 05:29:39 EDT (Sat, 19 Jul 2008)
New Revision: 47587
URL: http://svn.boost.org/trac/boost/changeset/47587

Log:
swap_object
Text files modified:
   sandbox/memory/boost/memory.hpp | 42 ++++++++++++++++++++++++++++++++++++++-
   sandbox/memory/boost/memory/basic.hpp | 2
   2 files changed, 41 insertions(+), 3 deletions(-)

Modified: sandbox/memory/boost/memory.hpp
==============================================================================
--- sandbox/memory/boost/memory.hpp (original)
+++ sandbox/memory/boost/memory.hpp 2008-07-19 05:29:39 EDT (Sat, 19 Jul 2008)
@@ -49,6 +49,26 @@
 #endif
 
 // -------------------------------------------------------------------------
+// function swap_object
+
+NS_BOOST_MEMORY_BEGIN
+
+inline void winx_call swap(void* a, void* b, size_t cb)
+{
+ void* t = _alloca(cb);
+ memcpy(t, a, cb);
+ memcpy(a, b, cb);
+ memcpy(b, t, cb);
+}
+
+template <class Type>
+void winx_call swap_object(Type* a, Type* b) {
+ swap(a, b, sizeof(Type));
+}
+
+NS_BOOST_MEMORY_END
+
+// -------------------------------------------------------------------------
 // class defragment
 
 NS_BOOST_MEMORY_BEGIN
@@ -66,8 +86,7 @@
         }
 
         void BOOST_MEMORY_CALL swap(defragment& o) {
- ContainerT::swap(o);
- alloc_type::swap(o.get_alloc());
+ swap_object(this, &o);
         }
 
         void BOOST_MEMORY_CALL defrag() {
@@ -142,6 +161,10 @@
         AllocT& BOOST_MEMORY_CALL get_alloc() const {
                 return *m_alloc;
         }
+
+ void BOOST_MEMORY_CALL swap(stl_allocator& o) {
+ std::swap(m_alloc, o.m_alloc);
+ }
 };
 
 #if !defined(BOOST_MEMORY_NO_PARTIAL_SPECIAILIZATION)
@@ -210,6 +233,21 @@
 NS_BOOST_MEMORY_END
 
 // -------------------------------------------------------------------------
+// std::swap
+
+namespace std {
+
+template <class Type, class AllocT>
+__forceinline void swap(
+ NS_BOOST_MEMORY::stl_allocator<Type, AllocT>& a,
+ NS_BOOST_MEMORY::stl_allocator<Type, AllocT>& b)
+{
+ a.swap(b);
+}
+
+} // namespace std
+
+// -------------------------------------------------------------------------
 
 namespace boost
 {

Modified: sandbox/memory/boost/memory/basic.hpp
==============================================================================
--- sandbox/memory/boost/memory/basic.hpp (original)
+++ sandbox/memory/boost/memory/basic.hpp 2008-07-19 05:29:39 EDT (Sat, 19 Jul 2008)
@@ -321,7 +321,7 @@
 
 #if defined(BOOST_MEMORY_NO_STRICT_EXCEPTION_SEMANTICS)
 //
-// Backard options:
+// Backward options:
 // not strict in accord with normal C++ semantics but a bit faster
 //
 #define BOOST_MEMORY_NEW(alloc, Type) \


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk