Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71139 - trunk/boost/interprocess/smart_ptr
From: igaztanaga_at_[hidden]
Date: 2011-04-09 04:45:38


Author: igaztanaga
Date: 2011-04-09 04:45:37 EDT (Sat, 09 Apr 2011)
New Revision: 71139
URL: http://svn.boost.org/trac/boost/changeset/71139

Log:
Non-throwing make_managed_shared_ptr version.
Text files modified:
   trunk/boost/interprocess/smart_ptr/shared_ptr.hpp | 21 +++++++++++++++++++++
   1 files changed, 21 insertions(+), 0 deletions(-)

Modified: trunk/boost/interprocess/smart_ptr/shared_ptr.hpp
==============================================================================
--- trunk/boost/interprocess/smart_ptr/shared_ptr.hpp (original)
+++ trunk/boost/interprocess/smart_ptr/shared_ptr.hpp 2011-04-09 04:45:37 EDT (Sat, 09 Apr 2011)
@@ -368,6 +368,27 @@
    );
 }
 
+//!Returns an instance of a shared pointer constructed
+//!with the default allocator and deleter from a pointer
+//!of type T that has been allocated in the passed managed segment.
+//!Does not throw, return null shared pointer in error.
+template<class T, class ManagedMemory>
+inline typename managed_shared_ptr<T, ManagedMemory>::type
+ make_managed_shared_ptr(T *constructed_object, ManagedMemory &managed_memory, std::nothrow_t)
+{
+ try{
+ return typename managed_shared_ptr<T, ManagedMemory>::type
+ ( constructed_object
+ , managed_memory.template get_allocator<void>()
+ , managed_memory.template get_deleter<T>()
+ );
+ }
+ catch(...){
+ return managed_shared_ptr<T, ManagedMemory>::type();
+ }
+}
+
+
 } // namespace interprocess
 
 /// @cond


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