+// Baruch Even baruch@ev-en.org 2001-02-20
+// This version is a modified version for use in LyX
+// The modifications are done in order to use it where exceptions are disabled
+// Currently it has no "no memory" checks in place, asserts are probably the
+// only real way.
+// all changed are #ifded'ed by LYX_NO_EXCEPTIONS
+#define LYX_NO_EXCEPTIONS
+
// Boost smart_ptr.hpp header file -----------------------------------------//
// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. Permission to copy,
typedef T element_type;
explicit shared_ptr(T* p =0) : px(p) {
+#ifndef LYX_NO_EXCEPTIONS
try { pn = new long(1); } // fix: prevent leak if new throws
catch (...) { delete p; throw; }
+#else
+ pn = new long(1);
+#endif
}
shared_ptr(const shared_ptr& r) : px(r.px) { ++*(pn = r.pn); } // never throws
if ( px == p ) return; // fix: self-assignment safe
if (--*pn == 0) { delete px; }
else { // allocate new reference counter
+#ifndef LYX_NO_EXCEPTIONS
try { pn = new long; } // fix: prevent leak if new throws
catch (...) {
++*pn; // undo effect of --*pn above to meet effects guarantee
delete p;
throw;
} // catch
+#else
+ pn = new long;
+#endif
} // allocate new reference counter
*pn = 1;
px = p;
typedef T element_type;
explicit shared_array(T* p =0) : px(p) {
+#ifndef LYX_NO_EXCEPTIONS
try { pn = new long(1); } // fix: prevent leak if new throws
catch (...) { delete [] p; throw; }
+#else
+ pn = new long(1);
+#endif
}
shared_array(const shared_array& r) : px(r.px) // never throws
if ( px == p ) return; // fix: self-assignment safe
if (--*pn == 0) { delete [] px; }
else { // allocate new reference counter
+#ifndef LYX_NO_EXCEPTIONS
try { pn = new long; } // fix: prevent leak if new throws
catch (...) {
++*pn; // undo effect of --*pn above to meet effects guarantee
delete [] p;
throw;
} // catch
+#else
+ pn = new long;
+#endif
} // allocate new reference counter
*pn = 1;
px = p;