次の方法で共有


allocate_shared

指定されたアロケーターを使用することによって、特定の型に割り当てられ構築されたオブジェクトに対して shared_ptr を作成します。 shared_ptr を返します。

template<class Type, class Allocator, class... Types>
    shared_ptr<Type> allocate_shared(
        Allocator Alloc, 
        Types&&... Args
    );

パラメーター

  • Alloc
    オブジェクトを作成するために使用されるアロケーター。

  • Args
    オブジェクトになるゼロ個以上の引数。

プロパティ値/戻り値

割り当てられたオブジェクトを指し示す shared_ptr を返します。

解説

関数は、Alloc によって割り当てられて構築されているように、shared_ptr<Type> オブジェクト、Type(Args...) へのポインターを作成します。

必要条件

ヘッダー: <memory>

名前空間: std

参照

関連項目

<memory>