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。