replace tabs
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@480 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
47e962d64b
commit
c69cdedf2e
2 changed files with 70 additions and 70 deletions
|
@ -25,7 +25,7 @@
|
|||
|
||||
namespace Loki
|
||||
{
|
||||
/////////////////////
|
||||
/////////////////////
|
||||
// template for the implementations
|
||||
/////////////////////
|
||||
template<class T>
|
||||
|
@ -45,12 +45,12 @@ namespace Loki
|
|||
struct AutoDeletePimpl
|
||||
{
|
||||
static void Destroy(T ptr)
|
||||
{
|
||||
typedef char T_must_be_defined[
|
||||
sizeof(typename TypeTraits<T>::PointeeType) ? 1 : -1 ];
|
||||
delete ptr;
|
||||
ptr = 0;
|
||||
}
|
||||
{
|
||||
typedef char T_must_be_defined[
|
||||
sizeof(typename TypeTraits<T>::PointeeType) ? 1 : -1 ];
|
||||
delete ptr;
|
||||
ptr = 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
@ -65,41 +65,41 @@ namespace Loki
|
|||
// Helper class AutoPtrHolder to manage pimpl lifetime
|
||||
/////////////////////
|
||||
|
||||
namespace Private
|
||||
namespace Private
|
||||
|
||||
{
|
||||
template
|
||||
<
|
||||
class Impl,
|
||||
class Ptr,
|
||||
template<class> class Del
|
||||
>
|
||||
struct AutoPtrHolder
|
||||
{
|
||||
AutoPtrHolder() //: ptr(Ptr()) this owerwrites the pointer to PtrImpl
|
||||
{} // when using DeclaredRimpl!!
|
||||
{
|
||||
template
|
||||
<
|
||||
class Impl,
|
||||
class Ptr,
|
||||
template<class> class Del
|
||||
>
|
||||
struct AutoPtrHolder
|
||||
{
|
||||
AutoPtrHolder() //: ptr(Ptr()) this owerwrites the pointer to PtrImpl
|
||||
{} // when using DeclaredRimpl!!
|
||||
|
||||
~AutoPtrHolder()
|
||||
{
|
||||
// delete automatically by the delete policy
|
||||
Del<Ptr>::Destroy( ptr );
|
||||
}
|
||||
~AutoPtrHolder()
|
||||
{
|
||||
// delete automatically by the delete policy
|
||||
Del<Ptr>::Destroy( ptr );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
operator T&()
|
||||
{
|
||||
Create();
|
||||
return *ptr;
|
||||
}
|
||||
template<class T>
|
||||
operator T&()
|
||||
{
|
||||
Create();
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
Ptr Create()
|
||||
{
|
||||
ptr = Ptr( new Impl );
|
||||
return ptr;
|
||||
}
|
||||
Ptr Create()
|
||||
{
|
||||
ptr = Ptr( new Impl );
|
||||
return ptr;
|
||||
}
|
||||
|
||||
Ptr ptr;
|
||||
};
|
||||
Ptr ptr;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct HavePtrHolder
|
||||
|
@ -116,7 +116,7 @@ namespace Loki
|
|||
|
||||
template<class Impl, typename Ptr, template<class> class Del>
|
||||
class InheritedPimpl : private
|
||||
Private::HavePtrHolder<Private::AutoPtrHolder<Impl,Ptr,Del> >
|
||||
Private::HavePtrHolder<Private::AutoPtrHolder<Impl,Ptr,Del> >
|
||||
{
|
||||
typedef Private::HavePtrHolder<Private::AutoPtrHolder<Impl,Ptr,Del> > PtrHolder;
|
||||
|
||||
|
@ -127,13 +127,13 @@ namespace Loki
|
|||
InheritedPimpl() : LOKI_INHERITED_PIMPL_NAME(PtrHolder::ptr.Create())
|
||||
{}
|
||||
|
||||
private:
|
||||
InheritedPimpl& operator=(const InheritedPimpl&);
|
||||
private:
|
||||
InheritedPimpl& operator=(const InheritedPimpl&);
|
||||
};
|
||||
|
||||
template<class Impl, typename Ptr, template<class> class Del>
|
||||
class DeclaredPimpl : private
|
||||
Private::HavePtrHolder<Private::AutoPtrHolder<Impl,Ptr,Del> >
|
||||
class DeclaredPimpl : private
|
||||
Private::HavePtrHolder<Private::AutoPtrHolder<Impl,Ptr,Del> >
|
||||
{
|
||||
typedef Private::HavePtrHolder<Private::AutoPtrHolder<Impl,Ptr,Del> > PtrHolder;
|
||||
|
||||
|
@ -149,11 +149,11 @@ namespace Loki
|
|||
}
|
||||
|
||||
protected:
|
||||
DeclaredPimpl() : ptr(PtrHolder::ptr.Create())
|
||||
DeclaredPimpl() : ptr(PtrHolder::ptr.Create())
|
||||
{}
|
||||
|
||||
private:
|
||||
DeclaredPimpl& operator=(const DeclaredPimpl&);
|
||||
DeclaredPimpl& operator=(const DeclaredPimpl&);
|
||||
const Ptr ptr;
|
||||
};
|
||||
|
||||
|
@ -164,7 +164,7 @@ namespace Loki
|
|||
|
||||
template<class Impl, typename Ptr, template<class> class Del>
|
||||
class InheritedRimpl : private
|
||||
Private::HavePtrHolder<Private::AutoPtrHolder<Impl,Ptr,Del> >
|
||||
Private::HavePtrHolder<Private::AutoPtrHolder<Impl,Ptr,Del> >
|
||||
{
|
||||
typedef Private::HavePtrHolder<Private::AutoPtrHolder<Impl,Ptr,Del> > PtrHolder;
|
||||
|
||||
|
@ -215,8 +215,8 @@ namespace Loki
|
|||
PtrImpl() : UsagePolicy<Impl,PointerPolicy,DeletePolicy>()
|
||||
{}
|
||||
|
||||
private:
|
||||
PtrImpl& operator=(const PtrImpl&);
|
||||
private:
|
||||
PtrImpl& operator=(const PtrImpl&);
|
||||
|
||||
};
|
||||
|
||||
|
@ -229,7 +229,7 @@ namespace Loki
|
|||
template<class T>
|
||||
struct Pimpl
|
||||
{
|
||||
// declare pimpl
|
||||
// declare pimpl
|
||||
typedef PtrImpl
|
||||
<
|
||||
Impl<T>,
|
||||
|
@ -239,7 +239,7 @@ namespace Loki
|
|||
>
|
||||
Type;
|
||||
|
||||
// inherit pimpl
|
||||
// inherit pimpl
|
||||
typedef PtrImpl
|
||||
<
|
||||
Impl<T>,
|
||||
|
@ -255,7 +255,7 @@ namespace Loki
|
|||
struct Rimpl
|
||||
{
|
||||
|
||||
// declare rimpl
|
||||
// declare rimpl
|
||||
typedef PtrImpl
|
||||
<
|
||||
Impl<T>,
|
||||
|
@ -265,8 +265,8 @@ namespace Loki
|
|||
>
|
||||
Type;
|
||||
|
||||
// init declared rimpl
|
||||
typedef Private::AutoPtrHolder
|
||||
// init declared rimpl
|
||||
typedef Private::AutoPtrHolder
|
||||
<
|
||||
Type,
|
||||
Type*,
|
||||
|
@ -275,7 +275,7 @@ namespace Loki
|
|||
Init;
|
||||
|
||||
|
||||
// ingerit rimpl
|
||||
// ingerit rimpl
|
||||
typedef PtrImpl
|
||||
<
|
||||
Impl<T>,
|
||||
|
|
|
@ -143,18 +143,18 @@ void test_more();
|
|||
|
||||
void heap_debug()
|
||||
{
|
||||
int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
|
||||
int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
|
||||
|
||||
// Turn on leak-checking bit
|
||||
tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
|
||||
// Turn on leak-checking bit
|
||||
tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
|
||||
|
||||
//tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF;
|
||||
//tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF;
|
||||
|
||||
// Turn off CRT block checking bit
|
||||
tmpFlag &= ~_CRTDBG_CHECK_CRT_DF;
|
||||
// Turn off CRT block checking bit
|
||||
tmpFlag &= ~_CRTDBG_CHECK_CRT_DF;
|
||||
|
||||
// Set flag to the new value
|
||||
_CrtSetDbgFlag( tmpFlag );
|
||||
// Set flag to the new value
|
||||
_CrtSetDbgFlag( tmpFlag );
|
||||
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ void heap_debug()
|
|||
|
||||
int main()
|
||||
{
|
||||
heap_debug();
|
||||
heap_debug();
|
||||
|
||||
A* a = new A;
|
||||
B* b = new B;
|
||||
|
@ -219,15 +219,15 @@ void test_more()
|
|||
{
|
||||
Loki::Printf("\n\nMore tests:\n");
|
||||
|
||||
Loki::Printf("\nCreating Pimpls\n");
|
||||
Loki::Printf("\nCreating Pimpls\n");
|
||||
P1* p1 = new P1;
|
||||
P2* p2 = new P2;
|
||||
P3* p3 = new P3;
|
||||
P4* p4 = new P4;
|
||||
P5* p5 = new P5;
|
||||
P6* p6 = new P6;
|
||||
P6* p6 = new P6;
|
||||
|
||||
Loki::Printf("\nCreating Rimpls\n");
|
||||
Loki::Printf("\nCreating Rimpls\n");
|
||||
R1* r1 = new R1;
|
||||
R2* r2 = new R2;
|
||||
R3* r3 = new R3;
|
||||
|
@ -236,16 +236,16 @@ void test_more()
|
|||
R6* r6 = new R6;
|
||||
|
||||
|
||||
Loki::Printf("\nDeleting Pimpls\n");
|
||||
delete p1;
|
||||
Loki::Printf("\nDeleting Pimpls\n");
|
||||
delete p1;
|
||||
delete p2;
|
||||
delete p3;
|
||||
delete p4;
|
||||
delete p5;
|
||||
delete p6;
|
||||
delete p6;
|
||||
|
||||
Loki::Printf("\nDeleting Rimpls\n");
|
||||
delete r1;
|
||||
delete r1;
|
||||
delete r2;
|
||||
delete r3;
|
||||
delete r4;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue