From 4e832788bfae6fdbfc1aac88c37b6dd47103c2ea Mon Sep 17 00:00:00 2001 From: John Maddock Date: Thu, 16 Nov 2000 11:17:22 +0000 Subject: [PATCH] Fix for egcs 1.1.1 problems with std::auto_ptr [SVN r8225] --- include/boost/smart_ptr.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/boost/smart_ptr.hpp b/include/boost/smart_ptr.hpp index 686df8d..59e42a7 100644 --- a/include/boost/smart_ptr.hpp +++ b/include/boost/smart_ptr.hpp @@ -139,12 +139,13 @@ template class shared_ptr { shared_ptr(const shared_ptr& r) : px(r.px) { // never throws ++*(pn = r.pn); } - +#ifndef BOOST_NO_AUTO_PTR template explicit shared_ptr(std::auto_ptr& r) { pn = new long(1); // may throw px = r.release(); // fix: moved here to stop leak if new throws - } + } +#endif template shared_ptr& operator=(const shared_ptr& r) { @@ -152,6 +153,7 @@ template class shared_ptr { return *this; } +#ifndef BOOST_NO_AUTO_PTR template shared_ptr& operator=(std::auto_ptr& r) { // code choice driven by guarantee of "no effect if new throws" @@ -164,7 +166,9 @@ template class shared_ptr { px = r.release(); // fix: moved here so doesn't leak if new throws return *this; } +#endif #else +#ifndef BOOST_NO_AUTO_PTR explicit shared_ptr(std::auto_ptr& r) { pn = new long(1); // may throw px = r.release(); // fix: moved here to stop leak if new throws @@ -181,6 +185,7 @@ template class shared_ptr { px = r.release(); // fix: moved here so doesn't leak if new throws return *this; } +#endif #endif void reset(T* p=0) { @@ -371,3 +376,4 @@ template #endif // BOOST_SMART_PTR_HPP +