bug 382: templated DynamicCast
This commit is contained in:
@@ -249,8 +249,8 @@ PtrTest::RunTests (void)
|
||||
Ptr<NoCount> p4 = CallTestConst (p1);
|
||||
Ptr<NoCount const> p5 = p4;
|
||||
//p4 = p5; You cannot make a const pointer be a non-const pointer.
|
||||
// but if you use const_pointer_cast, you can.
|
||||
p4 = const_pointer_cast<NoCount> (p5);
|
||||
// but if you use ConstCast, you can.
|
||||
p4 = ConstCast<NoCount> (p5);
|
||||
p5 = p1;
|
||||
Ptr<NoCount> p;
|
||||
if (p == 0)
|
||||
|
||||
@@ -361,11 +361,18 @@ bool operator >= (const Ptr<T> &lhs, const Ptr<T> &rhs)
|
||||
|
||||
template <typename T1, typename T2>
|
||||
Ptr<T1>
|
||||
const_pointer_cast (Ptr<T2> const&p)
|
||||
ConstCast (Ptr<T2> const&p)
|
||||
{
|
||||
return Ptr<T1> (const_cast<T1 *> (PeekPointer (p)));
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
Ptr<T1>
|
||||
DynamicCast (Ptr<T2> const&p)
|
||||
{
|
||||
return Ptr<T1> (dynamic_cast<T1 *> (PeekPointer (p)));
|
||||
}
|
||||
|
||||
|
||||
/****************************************************
|
||||
* Member method implementations.
|
||||
|
||||
Reference in New Issue
Block a user