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.
This commit is contained in:
parent
72b08a80c8
commit
0e8d822b18
@ -16,17 +16,21 @@
|
|||||||
|
|
||||||
#include <@KWSYS_NAMESPACE@/Configure.hxx>
|
#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
|
// auto_ptr_ref to pass an auto_ptr returned from one function
|
||||||
// directly to another function as in use_auto_ptr(get_auto_ptr()).
|
// 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++
|
// We do not use const_cast on other platforms to maintain the C++
|
||||||
// standard design and guarantee that if an auto_ptr is bound
|
// standard design and guarantee that if an auto_ptr is bound
|
||||||
// to a reference-to-const then ownership will be maintained.
|
// 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_REF 0
|
||||||
|
# define @KWSYS_NAMESPACE@_AUTO_PTR_CONST const
|
||||||
|
# define @KWSYS_NAMESPACE@_AUTO_PTR_CAST(a) cast(a)
|
||||||
#else
|
#else
|
||||||
# define @KWSYS_NAMESPACE@_AUTO_PTR_REF 1
|
# define @KWSYS_NAMESPACE@_AUTO_PTR_REF 1
|
||||||
|
# define @KWSYS_NAMESPACE@_AUTO_PTR_CONST
|
||||||
|
# define @KWSYS_NAMESPACE@_AUTO_PTR_CAST(a) a
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace @KWSYS_NAMESPACE@
|
namespace @KWSYS_NAMESPACE@
|
||||||
@ -58,13 +62,10 @@ template <class Y> struct auto_ptr_ref
|
|||||||
template <class X>
|
template <class X>
|
||||||
class auto_ptr
|
class auto_ptr
|
||||||
{
|
{
|
||||||
#if @KWSYS_NAMESPACE@_AUTO_PTR_REF
|
#if !@KWSYS_NAMESPACE@_AUTO_PTR_REF
|
||||||
typedef auto_ptr auto_ptr_source;
|
template <typename Y>
|
||||||
static inline auto_ptr& cast(auto_ptr_source& a) { return a; }
|
static inline auto_ptr<Y>& cast(auto_ptr<Y> const& a)
|
||||||
#else
|
{ return const_cast<auto_ptr<Y>&>(a); }
|
||||||
typedef auto_ptr const auto_ptr_source;
|
|
||||||
static inline auto_ptr& cast(auto_ptr_source& a)
|
|
||||||
{ return const_cast<auto_ptr&>(a); }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** The pointer to the object held. */
|
/** The pointer to the object held. */
|
||||||
@ -77,16 +78,17 @@ public:
|
|||||||
/** Construct from an auto_ptr holding a compatible object. This
|
/** Construct from an auto_ptr holding a compatible object. This
|
||||||
transfers ownership to the newly constructed auto_ptr. */
|
transfers ownership to the newly constructed auto_ptr. */
|
||||||
template <class Y>
|
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
|
/** Assign from an auto_ptr holding a compatible object. This
|
||||||
transfers ownership to the left-hand-side of the assignment. */
|
transfers ownership to the left-hand-side of the assignment. */
|
||||||
template <class Y>
|
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;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,15 +105,16 @@ public:
|
|||||||
/** Construct from another auto_ptr holding an object of the same
|
/** Construct from another auto_ptr holding an object of the same
|
||||||
type. This transfers ownership to the newly constructed
|
type. This transfers ownership to the newly constructed
|
||||||
auto_ptr. */
|
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.
|
/** Assign from another auto_ptr holding an object of the same type.
|
||||||
This transfers ownership to the newly constructed auto_ptr. */
|
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;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user