summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/auto_ptr.hxx.in
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-03-09 21:58:08 (GMT)
committerBrad King <brad.king@kitware.com>2007-03-09 21:58:08 (GMT)
commit0e8d822b180c73129017073815e6205c990cadf7 (patch)
tree98a0c244aa61a1c8a2a6d79aacbef68be629d843 /Source/kwsys/auto_ptr.hxx.in
parent72b08a80c8820d505e061e2511ac9244b28edfbb (diff)
downloadCMake-0e8d822b180c73129017073815e6205c990cadf7.zip
CMake-0e8d822b180c73129017073815e6205c990cadf7.tar.gz
CMake-0e8d822b180c73129017073815e6205c990cadf7.tar.bz2
COMP: Fix warning about binding reference-to-non-const to an rvalue on VS6. It does not seem to be doing the proper auto_ptr_ref conversions. Instead use the const_cast work-around on this platform.
Diffstat (limited to 'Source/kwsys/auto_ptr.hxx.in')
-rw-r--r--Source/kwsys/auto_ptr.hxx.in37
1 files changed, 20 insertions, 17 deletions
diff --git a/Source/kwsys/auto_ptr.hxx.in b/Source/kwsys/auto_ptr.hxx.in
index f8d4d3c..6d72443 100644
--- a/Source/kwsys/auto_ptr.hxx.in
+++ b/Source/kwsys/auto_ptr.hxx.in
@@ -16,17 +16,21 @@
#include <@KWSYS_NAMESPACE@/Configure.hxx>
-// The HP compiler cannot handle the conversions necessary to use
+// The HP compiler and VS6 cannot handle the conversions necessary to use
// auto_ptr_ref to pass an auto_ptr returned from one function
// directly to another function as in use_auto_ptr(get_auto_ptr()).
-// We instead use const_cast to achieve the syntax on that platform.
+// We instead use const_cast to achieve the syntax on those platforms.
// We do not use const_cast on other platforms to maintain the C++
// standard design and guarantee that if an auto_ptr is bound
// to a reference-to-const then ownership will be maintained.
-#if defined(__HP_aCC)
+#if defined(__HP_aCC) || (defined(_MSC_VER) && _MSC_VER <= 1200)
# define @KWSYS_NAMESPACE@_AUTO_PTR_REF 0
+# define @KWSYS_NAMESPACE@_AUTO_PTR_CONST const
+# define @KWSYS_NAMESPACE@_AUTO_PTR_CAST(a) cast(a)
#else
# define @KWSYS_NAMESPACE@_AUTO_PTR_REF 1
+# define @KWSYS_NAMESPACE@_AUTO_PTR_CONST
+# define @KWSYS_NAMESPACE@_AUTO_PTR_CAST(a) a
#endif
namespace @KWSYS_NAMESPACE@
@@ -58,13 +62,10 @@ template <class Y> struct auto_ptr_ref
template <class X>
class auto_ptr
{
-#if @KWSYS_NAMESPACE@_AUTO_PTR_REF
- typedef auto_ptr auto_ptr_source;
- static inline auto_ptr& cast(auto_ptr_source& a) { return a; }
-#else
- typedef auto_ptr const auto_ptr_source;
- static inline auto_ptr& cast(auto_ptr_source& a)
- { return const_cast<auto_ptr&>(a); }
+#if !@KWSYS_NAMESPACE@_AUTO_PTR_REF
+ template <typename Y>
+ static inline auto_ptr<Y>& cast(auto_ptr<Y> const& a)
+ { return const_cast<auto_ptr<Y>&>(a); }
#endif
/** The pointer to the object held. */
@@ -77,16 +78,17 @@ public:
/** Construct from an auto_ptr holding a compatible object. This
transfers ownership to the newly constructed auto_ptr. */
template <class Y>
- auto_ptr(auto_ptr<Y>& a) throw(): x_(a.release())
+ auto_ptr(auto_ptr<Y> @KWSYS_NAMESPACE@_AUTO_PTR_CONST& a) throw():
+ x_(@KWSYS_NAMESPACE@_AUTO_PTR_CAST(a).release())
{
}
/** Assign from an auto_ptr holding a compatible object. This
transfers ownership to the left-hand-side of the assignment. */
template <class Y>
- auto_ptr& operator=(auto_ptr<Y>& a) throw()
+ auto_ptr& operator=(auto_ptr<Y> @KWSYS_NAMESPACE@_AUTO_PTR_CONST& a) throw()
{
- this->reset(a.release());
+ this->reset(@KWSYS_NAMESPACE@_AUTO_PTR_CAST(a).release());
return *this;
}
@@ -99,19 +101,20 @@ public:
explicit auto_ptr(X* p=0) throw(): x_(p)
{
}
-
+
/** Construct from another auto_ptr holding an object of the same
type. This transfers ownership to the newly constructed
auto_ptr. */
- auto_ptr(auto_ptr_source& a) throw(): x_(cast(a).release())
+ auto_ptr(auto_ptr @KWSYS_NAMESPACE@_AUTO_PTR_CONST& a) throw():
+ x_(@KWSYS_NAMESPACE@_AUTO_PTR_CAST(a).release())
{
}
/** Assign from another auto_ptr holding an object of the same type.
This transfers ownership to the newly constructed auto_ptr. */
- auto_ptr& operator=(auto_ptr_source& a) throw()
+ auto_ptr& operator=(auto_ptr @KWSYS_NAMESPACE@_AUTO_PTR_CONST& a) throw()
{
- this->reset(cast(a).release());
+ this->reset(@KWSYS_NAMESPACE@_AUTO_PTR_CAST(a).release());
return *this;
}