Fix for egcs 1.1.1 problems with std::auto_ptr

[SVN r8225]
This commit is contained in:
John Maddock
2000-11-16 11:17:22 +00:00
parent db43d160b4
commit 4e832788bf

View File

@@ -139,12 +139,13 @@ template<typename T> class shared_ptr {
shared_ptr(const shared_ptr<Y>& r) : px(r.px) { // never throws
++*(pn = r.pn);
}
#ifndef BOOST_NO_AUTO_PTR
template<typename Y>
explicit shared_ptr(std::auto_ptr<Y>& r) {
pn = new long(1); // may throw
px = r.release(); // fix: moved here to stop leak if new throws
}
#endif
template<typename Y>
shared_ptr& operator=(const shared_ptr<Y>& r) {
@@ -152,6 +153,7 @@ template<typename T> class shared_ptr {
return *this;
}
#ifndef BOOST_NO_AUTO_PTR
template<typename Y>
shared_ptr& operator=(std::auto_ptr<Y>& r) {
// code choice driven by guarantee of "no effect if new throws"
@@ -164,7 +166,9 @@ template<typename T> 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<T>& r) {
pn = new long(1); // may throw
px = r.release(); // fix: moved here to stop leak if new throws
@@ -181,6 +185,7 @@ template<typename T> 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<typename T>
#endif // BOOST_SMART_PTR_HPP