ALLOCATOR_DECL (<allocators>)

为分配器模板选件类。

#define ALLOCATOR_DECL(cache, sync, name) <alloc_template>

备注

宏提供一起定义分配器模板选件类使用同步筛选器 sync 和一个缓存类型 cache的模板定义 template <class Type> class name {.....} 和专用化 template <> class name<void> {.....}。

对可生成rebind的编译器,发生的模板定义如下所示:

template <class Type> class name
    : public stdext::allocators::allocator_base<Type, sync<cache > >
    {
    public:
        name() {}
        template <class Other> name(const name<Other>&) {}
        template <class Other> name& operator = (const name<Other>&)
            {return *this; }
        template <class Other> struct rebind
            {    /* convert a name<Type> to a name<Other> */
            typedef name<Other> other;
            };
    };

用于不能生成rebind的编译器生成的模板定义如下所示:

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; }
    };

要求

标头: <allocators>

命名空间: stdext

请参见

参考

<allocators>