summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-03-02 04:28:17 (GMT)
committerBrad King <brad.king@kitware.com>2007-03-02 04:28:17 (GMT)
commita0e26986f7365ad91b7702dad5bb786911257cea (patch)
treeeb3198ecf52692edeeb5e7fe463c6b9828be473b
parentba6b7628e5de090f20316acb3a00a3ddf69bb63e (diff)
downloadCMake-a0e26986f7365ad91b7702dad5bb786911257cea.zip
CMake-a0e26986f7365ad91b7702dad5bb786911257cea.tar.gz
CMake-a0e26986f7365ad91b7702dad5bb786911257cea.tar.bz2
COMP: More workarounds for Borland.
-rw-r--r--Source/kwsys/auto_ptr.hxx.in9
1 files changed, 6 insertions, 3 deletions
diff --git a/Source/kwsys/auto_ptr.hxx.in b/Source/kwsys/auto_ptr.hxx.in
index 6b0befc..e931835 100644
--- a/Source/kwsys/auto_ptr.hxx.in
+++ b/Source/kwsys/auto_ptr.hxx.in
@@ -20,11 +20,14 @@ namespace @KWSYS_NAMESPACE@
template <class X> 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 <class Y> struct auto_ptr_ref
{
auto_ptr<Y>& p_;
- explicit auto_ptr_ref(auto_ptr<Y>& p): p_(p) {}
+ auto_ptr_ref(auto_ptr<Y>& 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<X> r) throw(): x_(r.p_.release()) {}
- template <class Y> operator auto_ptr_ref<Y>() throw() { return auto_ptr_ref<Y>(*this); }
+ template <class Y> operator auto_ptr_ref<Y>() throw() { return auto_ptr_ref<Y>(*this, 1); }
template <class Y> operator auto_ptr<Y>() throw() { return release(); }
auto_ptr& operator=(auto_ptr_ref<X> r) throw() { reset(r.p_.release()); return *this; }
};