78 template <
typename ReturnPo
inter,
typename OriginalPo
inter, CountedPo
interCastingState>
class CountedPtrCastImpl;
85 template <
typename ReturnPo
inter,
typename OriginalPo
inter> ReturnPointer*
CountedPtrInternalCast(
const OriginalPointer* Original);
100 TypePointedTo* Target;
110 : Target(InitialPointer), RefCount(InitialCount)
120 {
return ++RefCount; }
125 {
return --RefCount; }
161 {
return ++RefCount; }
166 {
return --RefCount; }
205 template <
typename T>
206 class ReferenceCountTraits
250 template <
typename CurrentReferenceCountType,
typename OtherReferenceCountType>
251 class ReferenceCountAdjuster
257 static void Acquire(CurrentReferenceCountType* & UpdateCounter, OtherReferenceCountType* & OtherCounter)
258 { UpdateCounter = CountedPtrInternalCast<CurrentReferenceCountType>(OtherCounter->GetMostDerived()); }
263 template <
typename InternalReferenceCount>
264 class ReferenceCountAdjuster<InternalReferenceCount,InternalReferenceCount>
270 static void Acquire(InternalReferenceCount* & UpdateCounter, InternalReferenceCount* & OtherCounter)
271 { UpdateCounter = OtherCounter; }
287 template <
typename TypePo
intedTo>
310 template <
typename AnyReferenceCountType>
311 void Acquire(AnyReferenceCountType* CounterToAcquire)
throw()
313 ReferenceCountAdjuster<RefCountType, AnyReferenceCountType>::Acquire(
_ReferenceCounter, CounterToAcquire);
346 explicit CountedPtr(TypePointedTo* PointerTarget = 0) throw()
362 {
Acquire( Original._ReferenceCounter ); }
367 template <
typename OtherPo
inter>
371 Acquire( Original._ReferenceCounter );
390 if (
this != &Other) {
392 Acquire(Other._ReferenceCounter);
403 void Reset(TypePointedTo* PointerTarget)
413 void reset(TypePointedTo* PointerTarget)
414 {
Reset (PointerTarget); }
435 if (
this != &Other) {
437 Acquire(Other._ReferenceCounter);
458 TypePointedTo*
Get()
const throw()
463 TypePointedTo*
get()
const throw()
488 operator bool()
const throw()
515 template <
typename ReturnPo
inter,
typename OriginalPo
inter, CountedPo
interCastingState>
516 class CountedPtrCastImpl
523 static ReturnPointer
Cast(OriginalPointer)
527 return ReturnPointer(0);
535 template <
typename OriginalPo
inter>
542 static OriginalPointer
Cast(OriginalPointer Original)
550 template <
typename ReturnPo
inter,
typename OriginalPo
inter>
557 static ReturnPointer
Cast(OriginalPointer)
558 {
return ReturnPointer(0); }
565 template <
typename ReturnPo
inter,
typename OriginalPo
inter>
574 static ReturnPointer
Cast(OriginalPointer Original)
575 {
return static_cast<ReturnPointer
>(Original); }
582 template <
typename ReturnPo
inter,
typename OriginalPo
inter>
591 static ReturnPointer
Cast(OriginalPointer Original)
592 {
return dynamic_cast<ReturnPointer
>(Original); }
599 template <
typename ReturnPo
inter,
typename OriginalPo
inter>
608 static ReturnPointer
Cast(OriginalPointer Original)
609 {
return dynamic_cast<ReturnPointer
>(Original); }
619 template <
typename ReturnPo
inter,
typename OriginalPo
inter>
631 const_cast<OriginalPointer*>(Original)
642 template <
typename Po
inter>
651 template <
typename ReturnType,
typename OtherPo
interTargetType>
660 template <
typename ReturnType,
typename OtherPo
interTargetType>
669 template <
typename ReturnType,
typename OtherPo
interTargetType>
676 #endif // _smartptr_h