template<typename T>
class Proud::RefCount< T >
Smart pointer class. Please refer to <a target="_blank" href="http://guide.nettention.com/cpp_en#smart_ptr" >Smart Pointer</a>.
When using RefCount, the following must be considered.
- When RefCount refers object for the first time, it creates Tombstone. And when joint reference object appears, this tombstone will be shared.
In other words, there is a time cost(memory allocation, 1 time) to create tombstone initially.
- Cannot cast to related class types that are different to each other. Which means, RefCount<CFile> cannot be copied to RefCount<CObject>.
Type cast must be performed each time when coding as class type of RefCount entered higher possible base class.
class Base {};
class A:public Base {};
void Foo()
{
RefCount<A> a;
RefCount<Base> b;
a = b;
}
void Foo2()
{
RefCount<Base> a;
RefCount<Base> b(new A);
a = b;
A* p = (A*)a.get();
}
- Parameters
-
T | Type of object that is to be handled by smart pointer |
AllocT | one of the values of AllocType |
IsThreadSafe | <NEVER USED!> If true then it is safe that many threads handle the variable of this smart pointer. But it reduces overall performance. |