From a0e26986f7365ad91b7702dad5bb786911257cea Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 1 Mar 2007 23:28:17 -0500 Subject: [PATCH] COMP: More workarounds for Borland. --- Source/kwsys/auto_ptr.hxx.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/kwsys/auto_ptr.hxx.in b/Source/kwsys/auto_ptr.hxx.in index 6b0befc61..e93183568 100644 --- a/Source/kwsys/auto_ptr.hxx.in +++ b/Source/kwsys/auto_ptr.hxx.in @@ -20,11 +20,14 @@ namespace @KWSYS_NAMESPACE@ template class auto_ptr; // The auto_ptr_ref template is supposed to be a private member of -// auto_ptr but Borland 5.8 cannot handle it. +// auto_ptr but Borland 5.8 cannot handle it. The extra constructor +// argument prevents implicit conversion to auto_ptr_ref from auto_ptr +// through the constructor. This avoids problems on Borland compilers +// when returning auto_ptr by value from a function. template struct auto_ptr_ref { auto_ptr& p_; - explicit auto_ptr_ref(auto_ptr& p): p_(p) {} + auto_ptr_ref(auto_ptr& p, int): p_(p) {} }; // C++98 Standard Section 20.4.5 - Template class auto_ptr. @@ -53,7 +56,7 @@ public: void reset(X* p=0) throw() { if(get() != p) { delete get(); x_ = p; } } auto_ptr(auto_ptr_ref r) throw(): x_(r.p_.release()) {} - template operator auto_ptr_ref() throw() { return auto_ptr_ref(*this); } + template operator auto_ptr_ref() throw() { return auto_ptr_ref(*this, 1); } template operator auto_ptr() throw() { return release(); } auto_ptr& operator=(auto_ptr_ref r) throw() { reset(r.p_.release()); return *this; } };