add support of allocators with a standard interface, thanks to Miguel A. Figueroa-Villanueva
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@486 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
081c3fb31f
commit
d2e3bf1855
1 changed files with 32 additions and 0 deletions
|
@ -223,6 +223,35 @@ namespace Loki
|
||||||
{ delete p; }
|
{ delete p; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \struct CreateUsing
|
||||||
|
///
|
||||||
|
/// \ingroup CreationGroup
|
||||||
|
/// Implementation of the CreationPolicy used by SingletonHolder
|
||||||
|
/// Creates objects using a custom allocater.
|
||||||
|
/// Usage: e.g. CreateUsing<std::allocator>::Allocator
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template<template<class> class Alloc>
|
||||||
|
struct CreateUsing
|
||||||
|
{
|
||||||
|
template <class T>
|
||||||
|
struct Allocator
|
||||||
|
{
|
||||||
|
static Alloc<T> allocator;
|
||||||
|
|
||||||
|
static T* Create()
|
||||||
|
{
|
||||||
|
return new (allocator.allocate(1)) T;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Destroy(T* p)
|
||||||
|
{
|
||||||
|
//allocator.destroy(p);
|
||||||
|
p->~T();
|
||||||
|
allocator.deallocate(p,1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \struct CreateUsingMalloc
|
/// \struct CreateUsingMalloc
|
||||||
|
@ -804,6 +833,9 @@ namespace Loki
|
||||||
#endif // SINGLETON_INC_
|
#endif // SINGLETON_INC_
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.20 2006/01/16 19:56:30 syntheticpp
|
||||||
|
// add support of allocators with a standard interface, thanks to Miguel A. Figueroa-Villanueva
|
||||||
|
//
|
||||||
// Revision 1.19 2006/01/16 19:05:09 rich_sposato
|
// Revision 1.19 2006/01/16 19:05:09 rich_sposato
|
||||||
// Added cvs keywords.
|
// Added cvs keywords.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue