fix SmartPtr conversion issues
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@134 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
de3e4bf67c
commit
5896652d4d
1 changed files with 23 additions and 36 deletions
|
@ -926,21 +926,6 @@ namespace Loki
|
||||||
bool operator!() const // Enables "if (!sp) ..."
|
bool operator!() const // Enables "if (!sp) ..."
|
||||||
{ return GetImpl(*this) == 0; }
|
{ return GetImpl(*this) == 0; }
|
||||||
|
|
||||||
inline friend bool operator==(const SmartPtr& lhs,
|
|
||||||
const T* rhs)
|
|
||||||
{ return GetImpl(lhs) == rhs; }
|
|
||||||
|
|
||||||
inline friend bool operator==(const T* lhs,
|
|
||||||
const SmartPtr& rhs)
|
|
||||||
{ return rhs == lhs; }
|
|
||||||
|
|
||||||
inline friend bool operator!=(const SmartPtr& lhs,
|
|
||||||
const T* rhs)
|
|
||||||
{ return !(lhs == rhs); }
|
|
||||||
|
|
||||||
inline friend bool operator!=(const T* lhs,
|
|
||||||
const SmartPtr& rhs)
|
|
||||||
{ return rhs != lhs; }
|
|
||||||
|
|
||||||
// Ambiguity buster
|
// Ambiguity buster
|
||||||
template
|
template
|
||||||
|
@ -952,7 +937,7 @@ namespace Loki
|
||||||
template <class> class SP1
|
template <class> class SP1
|
||||||
>
|
>
|
||||||
bool operator==(const SmartPtr<T1, OP1, CP1, KP1, SP1>& rhs) const
|
bool operator==(const SmartPtr<T1, OP1, CP1, KP1, SP1>& rhs) const
|
||||||
{ return *this == GetImpl(rhs); }
|
{ return GetImpl(*this) == GetImpl(rhs); }
|
||||||
|
|
||||||
// Ambiguity buster
|
// Ambiguity buster
|
||||||
template
|
template
|
||||||
|
@ -976,24 +961,26 @@ namespace Loki
|
||||||
template <class> class SP1
|
template <class> class SP1
|
||||||
>
|
>
|
||||||
bool operator<(const SmartPtr<T1, OP1, CP1, KP1, SP1>& rhs) const
|
bool operator<(const SmartPtr<T1, OP1, CP1, KP1, SP1>& rhs) const
|
||||||
{ return *this < GetImpl(rhs); }
|
{ return GetImpl(*this) < GetImpl(rhs); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Helper for enabling 'if (sp)'
|
// Helper for enabling 'if (sp)'
|
||||||
struct Tester
|
struct Tester
|
||||||
{
|
{
|
||||||
Tester() {}
|
Tester(int) {}
|
||||||
private:
|
void dummy() {}
|
||||||
void operator delete(void*);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (Tester::*unspecified_boolean_type_)();
|
||||||
|
|
||||||
|
typedef typename Select<CP::allow, Tester, unspecified_boolean_type_>::Result
|
||||||
|
unspecified_boolean_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// enable 'if (sp)'
|
// enable 'if (sp)'
|
||||||
operator Tester*() const
|
operator unspecified_boolean_type() const
|
||||||
{
|
{
|
||||||
if (!*this) return 0;
|
return !*this ? 0 : &Tester::dummy;
|
||||||
static Tester t;
|
|
||||||
return &t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1029,7 +1016,7 @@ namespace Loki
|
||||||
typename U
|
typename U
|
||||||
>
|
>
|
||||||
inline bool operator==(const SmartPtr<T, OP, CP, KP, SP>& lhs,
|
inline bool operator==(const SmartPtr<T, OP, CP, KP, SP>& lhs,
|
||||||
const U* rhs)
|
U* rhs)
|
||||||
{ return GetImpl(lhs) == rhs; }
|
{ return GetImpl(lhs) == rhs; }
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1045,7 +1032,7 @@ namespace Loki
|
||||||
template <class> class SP,
|
template <class> class SP,
|
||||||
typename U
|
typename U
|
||||||
>
|
>
|
||||||
inline bool operator==(const U* lhs,
|
inline bool operator==(U* lhs,
|
||||||
const SmartPtr<T, OP, CP, KP, SP>& rhs)
|
const SmartPtr<T, OP, CP, KP, SP>& rhs)
|
||||||
{ return rhs == lhs; }
|
{ return rhs == lhs; }
|
||||||
|
|
||||||
|
@ -1063,7 +1050,7 @@ namespace Loki
|
||||||
typename U
|
typename U
|
||||||
>
|
>
|
||||||
inline bool operator!=(const SmartPtr<T, OP, CP, KP, SP>& lhs,
|
inline bool operator!=(const SmartPtr<T, OP, CP, KP, SP>& lhs,
|
||||||
const U* rhs)
|
U* rhs)
|
||||||
{ return !(lhs == rhs); }
|
{ return !(lhs == rhs); }
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1079,7 +1066,7 @@ namespace Loki
|
||||||
template <class> class SP,
|
template <class> class SP,
|
||||||
typename U
|
typename U
|
||||||
>
|
>
|
||||||
inline bool operator!=(const U* lhs,
|
inline bool operator!=(U* lhs,
|
||||||
const SmartPtr<T, OP, CP, KP, SP>& rhs)
|
const SmartPtr<T, OP, CP, KP, SP>& rhs)
|
||||||
{ return rhs != lhs; }
|
{ return rhs != lhs; }
|
||||||
|
|
||||||
|
@ -1097,7 +1084,7 @@ namespace Loki
|
||||||
typename U
|
typename U
|
||||||
>
|
>
|
||||||
inline bool operator<(const SmartPtr<T, OP, CP, KP, SP>& lhs,
|
inline bool operator<(const SmartPtr<T, OP, CP, KP, SP>& lhs,
|
||||||
const U* rhs);
|
U* rhs);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// operator< for lhs = raw pointer, rhs = SmartPtr -- NOT DEFINED
|
// operator< for lhs = raw pointer, rhs = SmartPtr -- NOT DEFINED
|
||||||
|
@ -1112,7 +1099,7 @@ namespace Loki
|
||||||
template <class> class SP,
|
template <class> class SP,
|
||||||
typename U
|
typename U
|
||||||
>
|
>
|
||||||
inline bool operator<(const U* lhs,
|
inline bool operator<(U* lhs,
|
||||||
const SmartPtr<T, OP, CP, KP, SP>& rhs);
|
const SmartPtr<T, OP, CP, KP, SP>& rhs);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1129,7 +1116,7 @@ namespace Loki
|
||||||
typename U
|
typename U
|
||||||
>
|
>
|
||||||
inline bool operator>(const SmartPtr<T, OP, CP, KP, SP>& lhs,
|
inline bool operator>(const SmartPtr<T, OP, CP, KP, SP>& lhs,
|
||||||
const U* rhs)
|
U* rhs)
|
||||||
{ return rhs < lhs; }
|
{ return rhs < lhs; }
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1145,7 +1132,7 @@ namespace Loki
|
||||||
template <class> class SP,
|
template <class> class SP,
|
||||||
typename U
|
typename U
|
||||||
>
|
>
|
||||||
inline bool operator>(const U* lhs,
|
inline bool operator>(U* lhs,
|
||||||
const SmartPtr<T, OP, CP, KP, SP>& rhs)
|
const SmartPtr<T, OP, CP, KP, SP>& rhs)
|
||||||
{ return rhs < lhs; }
|
{ return rhs < lhs; }
|
||||||
|
|
||||||
|
@ -1163,7 +1150,7 @@ namespace Loki
|
||||||
typename U
|
typename U
|
||||||
>
|
>
|
||||||
inline bool operator<=(const SmartPtr<T, OP, CP, KP, SP>& lhs,
|
inline bool operator<=(const SmartPtr<T, OP, CP, KP, SP>& lhs,
|
||||||
const U* rhs)
|
U* rhs)
|
||||||
{ return !(rhs < lhs); }
|
{ return !(rhs < lhs); }
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1179,7 +1166,7 @@ namespace Loki
|
||||||
template <class> class SP,
|
template <class> class SP,
|
||||||
typename U
|
typename U
|
||||||
>
|
>
|
||||||
inline bool operator<=(const U* lhs,
|
inline bool operator<=(U* lhs,
|
||||||
const SmartPtr<T, OP, CP, KP, SP>& rhs)
|
const SmartPtr<T, OP, CP, KP, SP>& rhs)
|
||||||
{ return !(rhs < lhs); }
|
{ return !(rhs < lhs); }
|
||||||
|
|
||||||
|
@ -1197,7 +1184,7 @@ namespace Loki
|
||||||
typename U
|
typename U
|
||||||
>
|
>
|
||||||
inline bool operator>=(const SmartPtr<T, OP, CP, KP, SP>& lhs,
|
inline bool operator>=(const SmartPtr<T, OP, CP, KP, SP>& lhs,
|
||||||
const U* rhs)
|
U* rhs)
|
||||||
{ return !(lhs < rhs); }
|
{ return !(lhs < rhs); }
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1213,7 +1200,7 @@ namespace Loki
|
||||||
template <class> class SP,
|
template <class> class SP,
|
||||||
typename U
|
typename U
|
||||||
>
|
>
|
||||||
inline bool operator>=(const U* lhs,
|
inline bool operator>=(U* lhs,
|
||||||
const SmartPtr<T, OP, CP, KP, SP>& rhs)
|
const SmartPtr<T, OP, CP, KP, SP>& rhs)
|
||||||
{ return !(lhs < rhs); }
|
{ return !(lhs < rhs); }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue