次の方法で共有


<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 を生成します。

関連項目

<allocators>