<allocators>標頭提供以下巨集:
ALLOCATOR_DECL
產生配置器類別範本。
#define ALLOCATOR_DECL(cache, sync, name) <alloc_template>
備註
巨集產生一個範本定義 template <class Type> class name {.....} 與一個專門化 template <> class name<void> {.....} ,兩者共同定義一個配置器類別範本,該範本使用同步過濾器 sync 及型別 cache為 的快取。
針對可以編譯重新繫結的編譯器,產生的範本定義看起來如下︰
struct rebind
{ /* convert a name<Type> to a name<Other> */
typedef name<Other> other;
};
針對無法編譯重新繫結的編譯器,產生的範本定義看起來如下︰
template <class Type<class name
: public stdext::allocators::allocator_base<Type,
sync<stdext::allocators::rts_alloc<cache>>>
{
public:
name() {}
template <class Other>
name(const name<Other>&) {}
template <class Other>
name& operator= (const name<Other>&)
{
return *this;
}
};
CACHE_CHUNKLIST
產出 stdext::allocators::cache_chunklist<sizeof(Type)>。
#define CACHE_CHUNKLIST <cache_class>
CACHE_FREELIST
產出 stdext::allocators::cache_freelist<sizeof(Type), max>。
#define CACHE_FREELIST(max) <cache_class>
CACHE_SUBALLOC
產出 stdext::allocators::cache_suballoc<sizeof(Type)>。
#define CACHE_SUBALLOC <cache_class>
SYNC_DEFAULT
產生同步處理篩選。
#define SYNC_DEFAULT <sync_template>
備註
如果編譯器支援編譯單執行緒和多執行緒應用程式,對於單執行緒應用程式,巨集會 stdext::allocators::sync_none產生;在其他情況下,則會 stdext::allocators::sync_shared產生 。