std::allocate_shared
提供:cppreference.com
< cpp | memory | shared ptr
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <memory>
|
||
| template< class T, class Alloc, class... Args > shared_ptr<T> allocate_shared( const Alloc& alloc, Args... args ); |
||
タイプ
Tのオブジェクトを構築し、std::shared_ptrのコンストラクタのパラメータリストとしてargsを使用Tにラップ.Original:
Constructs an object of type
T and wraps it in a std::shared_ptr using args as the parameter list for the constructor of T.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
すべてのメモリ割り当てはalloc要件を満たす
Allocatorのコピーを使用して行われます.Original:
All memory allocation is done using a copy of alloc, which satisfies the
Allocator requirements.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集] パラメータ
| alloc | - | The Allocator to use.
|
| args... | - | Tのインスタンスが構築されると引数のリスト.Original: list of arguments with which an instance of T will be constructed.The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[編集] 値を返します
std::shared_ptrタイプ
Tのインスタンスの.Original:
std::shared_ptr of an instance of type
T.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例外
Alloc::allocate()から、または
Tのコンストラクタからスローされた例外をスローすることができます.Original:
Can throw the exceptions thrown from Alloc::allocate() or from the constructor of
T.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] ノート
この関数は、単一のメモリ割り当てとTオブジェクト用とshared_ptrの制御ブロックにメモリを割り当てます。これとは対照的に、宣言
std::shared_ptr<T> p(new T(Args...))不要なオーバーヘッドを被るかもしれない2つのメモリの割り当てを行う.Original:
This function allocates memory for the T object and for the shared_ptr's control block with a single memory allocation. In contrast, the declaration
std::shared_ptr<T> p(new T(Args...)) performs two memory allocations, which may incur unnecessary overhead.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
共有と弱い両方の参照カウントがゼロに達すると、それがそれを解放するために使用することができるように
allocのコピーは、制御ブロックの一部として保存されます.Original:
A copy of
alloc is stored as part of the control block so that it can be used to deallocate it once both shared and weak reference counts reach zero.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] も参照してください
constructs new shared_ptr (パブリックメンバ関数) | |
| 新しいオブジェクトを管理し共有ポインタを作成します Original: creates a shared pointer that manages a new object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |