]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/detail/shared_ptr_nmt.hpp
Fixed some lines that were too long. It compiled afterwards.
[lyx.git] / boost / boost / detail / shared_ptr_nmt.hpp
index 79d5b5d92dbf1d03e2d3fbf3e3d0247e888f71d5..0780e305b599040249aa77b8462c1de1a177ef81 100644 (file)
@@ -7,24 +7,25 @@
 //  (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
 //  Copyright (c) 2001, 2002 Peter Dimov
 //
-//  Permission to copy, use, modify, sell and distribute this software
-//  is granted provided this copyright notice appears in all copies.
-//  This software is provided "as is" without express or implied
-//  warranty, and with no claim as to its suitability for any purpose.
+//  Distributed under the Boost Software License, Version 1.0. (See
+//  accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
 //
 //  See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation.
 //
 
 #include <boost/assert.hpp>
 #include <boost/checked_delete.hpp>
+#include <boost/throw_exception.hpp>
 #include <boost/detail/atomic_count.hpp>
 
 #ifndef BOOST_NO_AUTO_PTR
-#include <memory>             // for std::auto_ptr
+# include <memory>          // for std::auto_ptr
 #endif
 
-#include <algorithm>          // for std::swap
-#include <functional>         // for std::less
+#include <algorithm>        // for std::swap
+#include <functional>       // for std::less
+#include <new>              // for std::bad_alloc
 
 namespace boost
 {
@@ -38,25 +39,40 @@ private:
 public:
 
     typedef T element_type;
+    typedef T value_type;
 
     explicit shared_ptr(T * p = 0): px(p)
     {
+#ifndef BOOST_NO_EXCEPTIONS
+
         try  // prevent leak if new throws
         {
             pn = new count_type(1);
         }
         catch(...)
         {
-            checked_delete(p);
+            boost::checked_delete(p);
             throw;
-        } 
+        }
+
+#else
+
+        pn = new count_type(1);
+
+        if(pn == 0)
+        {
+            boost::checked_delete(p);
+            boost::throw_exception(std::bad_alloc());
+        }
+
+#endif
     }
 
     ~shared_ptr()
     {
         if(--*pn == 0)
         {
-            checked_delete(px);
+            boost::checked_delete(px);
             delete pn;
         }
     }