diff --git a/Source/kwsys/auto_ptr.hxx.in b/Source/kwsys/auto_ptr.hxx.in index 89a9de665..4306884a6 100644 --- a/Source/kwsys/auto_ptr.hxx.in +++ b/Source/kwsys/auto_ptr.hxx.in @@ -26,14 +26,14 @@ namespace detail // a private namespace. template struct auto_ptr_ref { - auto_ptr& p_; + Y* p_; // The extra constructor argument prevents implicit conversion to // auto_ptr_ref from auto_ptr through the constructor. Normally // this should be done with the explicit keyword but Borland 5.x // generates code in the conversion operator to call itself // infinately. - auto_ptr_ref(auto_ptr& p, int): p_(p) {} + auto_ptr_ref(Y* p, int): p_(p) {} }; } @@ -136,7 +136,7 @@ public: /** Construct from an auto_ptr_ref. This is used when the constructor argument is a call to a function returning an auto_ptr. */ - auto_ptr(detail::auto_ptr_ref r) throw(): x_(r.p_.release()) + auto_ptr(detail::auto_ptr_ref r) throw(): x_(r.p_) { } @@ -145,7 +145,7 @@ public: another auto_ptr. */ template operator detail::auto_ptr_ref() throw() { - return detail::auto_ptr_ref(*this, 1); + return detail::auto_ptr_ref(this->release(), 1); } /** Convert to an auto_ptr holding an object of a compatible type. @@ -160,7 +160,7 @@ public: assignment. */ auto_ptr& operator=(detail::auto_ptr_ref r) throw() { - this->reset(r.p_.release()); + this->reset(r.p_); return *this; } }; diff --git a/Source/kwsys/testAutoPtr.cxx b/Source/kwsys/testAutoPtr.cxx index 52344280e..aa44cb6f4 100644 --- a/Source/kwsys/testAutoPtr.cxx +++ b/Source/kwsys/testAutoPtr.cxx @@ -123,6 +123,7 @@ int testAutoPtr(int, char*[]) } #if 0 + // Is this allowed by the standard? { int received = function_call(generate_auto_ptr_B()); ASSERT(received, @@ -144,22 +145,18 @@ int testAutoPtr(int, char*[]) "auto_ptr empty after assignment from factory function"); } -#if 0 { kwsys::auto_ptr pa(generate_auto_ptr_B()); ASSERT(pa.get(), "auto_ptr empty after construction from compatible factory function"); } -#endif -#if 0 { kwsys::auto_ptr pa; pa = generate_auto_ptr_B(); ASSERT(pa.get(), "auto_ptr empty after assignment from compatible factory function"); } -#endif } ASSERT(instances == 0, "auto_ptr leaked an object");