名前空間
変種
操作

std::shared_ptr

提供: cppreference.com
< cpp‎ | memory


 
 
ユーティリティライブラリ
支援を入力します (basic types, RTTI, type traits)
動的なメモリ管理
エラー処理
プログラムユーティリティ
可変個引数関数
日付と時刻
関数オブジェクト
initializer_list(C++11)
bitset
hash(C++11)
関係演算子
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
ペアとタプル
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
フォワード、スワップ、および移動
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
動的なメモリ管理
低レベルのメモリ管理
アロケータ
Original:
Allocators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
allocator
allocator_traits(C++11)
allocator_arg_t(C++11)
allocator_arg(C++11)
uses_allocator(C++11)
scoped_allocator_adaptor(C++11)
ストレージを初期化されていない
Original:
Uninitialized storage
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
uninitialized_copy
uninitialized_copy_n(C++11)
uninitialized_fill
uninitialized_fill_n
raw_storage_iterator
get_temporary_buffer
return_temporary_buffer
スマートポインタ
Original:
Smart pointers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
unique_ptr(C++11)
shared_ptr(C++11)
weak_ptr(C++11)
auto_ptr(廃止予定)
owner_less(C++11)
enable_shared_from_this(C++11)
bad_weak_ptr(C++11)
default_delete(C++11)
ガベージコレクションをサポートしています
Original:
Garbage collection support
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
declare_reachable(C++11)
undeclare_reachable(C++11)
declare_no_pointers(C++11)
undeclare_no_pointers(C++11)
pointer_safety(C++11)
get_pointer_safety(C++11)
その他
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pointer_traits(C++11)
addressof(C++11)
align(C++11)
Cライブラリ
Original:
C Library
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
メンバ関数
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptr::shared_ptr
shared_ptr::~shared_ptr
shared_ptr::operator=
修飾子
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptr::reset
shared_ptr::swap
オブザーバー
Original:
Observers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptr::get
shared_ptr::operator*
shared_ptr::operator->
shared_ptr::use_count
shared_ptr::unique
shared_ptr::operator bool
shared_ptr::owner_before
非メンバ関数
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::swap
make_shared
allocate_shared
static_pointer_cast
dynamic_pointer_cast
const_pointer_cast
get_deleter
operator==
operator|=
operator<
operator<=
operator>
operator>=
operator<<
atomic_is_lock_free
atomic_load
atomic_load_explicit
atomic_store
atomic_store_explicit
atomic_exchange
atomic_exchange_explicit
atomic_compare_exchange_weak
atomic_compare_exchange_strong
atomic_compare_exchange_weak_explicit
atomic_compare_exchange_strong_explicit
std::hash
 
Defined in header <memory>
template< class T > class shared_ptr;
(C + + 11以来)
std::shared_ptrポインタを通じてオブジェクトの共有所有権を保持するスマートポインタです。いくつかのshared_ptrオブジェクトが同じオブジェクトを所有するかもしれない、それを指している最後に残っているshared_ptrが破壊またはリセットされたときに、オブジェクトが破棄されます。オブジェクトがdelete-expressionまたは建設中shared_ptrに供給され、カスタムデリータを使用して破壊された.
Original:
std::shared_ptr is a smart pointer that retains shared ownership of an object through a pointer. Several shared_ptr objects may own the same object; the object is destroyed when the last remaining shared_ptr pointing to it is destroyed or reset. The object is destroyed using delete-expression or a custom deleter that is supplied to shared_ptr during construction.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptrも何のオブジェクトを所有してないかもしれませんが、その場合、それが呼び出される.
Original:
A shared_ptr may also own no objects, in which case it is called empty.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptrCopyConstructibleの要件を満たしており、CopyAssignable.
Original:
shared_ptr meets the requirements of CopyConstructible and CopyAssignable.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] メンバータイプ

メンバー·タイプ
Original:
Member type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
element_type T

[編集] メンバ関数

constructs new shared_ptr
(パブリックメンバ関数) [edit]
それにはもっとshared_ptrsリンクする場合所有オブジェクトを破棄します
Original:
destructs the owned object if no more shared_ptrs link to it
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
shared_ptrを割り当てます
Original:
assigns the shared_ptr
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
修飾子
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
管理対象オブジェクトを置き換えます
Original:
replaces the managed object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
スワップの管理対象オブジェクト
Original:
swaps the managed objects
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
オブザーバー
Original:
Observers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
管理対象オブジェクトへのポインタを返します
Original:
returns a pointer to the managed object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
管理対象オブジェクトへの間接参照はポインタ
Original:
dereferences pointer to the managed object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
同じ管理対象オブジェクトを参照shared_ptrオブジェクトの数を返します
Original:
returns the number of shared_ptr objects referring to the same managed object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
管理対象オブジェクトが、現在のshared_ptrインスタンスによって管理されているかどうかをチェックします
Original:
checks whether the managed object is managed only by the current shared_ptr instance
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
管理対象オブジェクトが関連付けられているかどうかをチェックします
Original:
checks if there is associated managed object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
提供者ベースの共有ポインタの順序
Original:
provides owner-based ordering of shared pointers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]

[編集] 非メンバ関数

新しいオブジェクトを管理し共有ポインタを作成します
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.

(関数テンプレート) [edit]
アロケータを使用して割り当てられた新しいオブジェクトを管理し共有ポインタを作成します
Original:
creates a shared pointer that manages a new object allocated using an allocator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]
適用static_castdynamic_castconst_castまたは管理対象オブジェクトのタイプに
Original:
applies static_cast, dynamic_cast or const_cast to the type of the managed object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]
所有している場合、指定された型のデリータを返します
Original:
returns the deleter of specified type, if owned
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]
shared_ptr、またはnullptrと比較します
Original:
compares with another shared_ptr or with nullptr
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]
出力ストリームへのマネージポインタの値を出力します
Original:
outputs the value of the managed pointer to an output stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]
std::swapアルゴリズムを専門としています
Original:
specializes the std::swap algorithm
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]
アトミック操作を専門としています
Original:
specializes atomic operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]

[編集] ヘルパークラス

std::shared_ptrハッシュをサポート
Original:
hash support for std::shared_ptr
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(クラステンプレートの特殊化の2つの値を比較します) [edit]

[編集] 実装上の注意

典型的な実装では、std::shared_ptrは2つだけのポインタを保持します
Original:
In a typical implementation, std::shared_ptr holds only two pointers:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 参照されたオブジェクトへのポインタ
    Original:
    a pointer to the referenced object
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 制御ブロックへのポインタ
    Original:
    a pointer to control block
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
:制御ブロックは、保持している動的に割り当てられたオブジェクトです
Original:
Where the control block is a dynamically-allocated object that holds:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 管理対象オブジェクト、または管理対象オブジェクト自身へのポインタ
    Original:
    a pointer to the managed object or the managed object itself
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • デリータ
    Original:
    the deleter
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • アロケータ
    Original:
    the allocator
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 管理対象オブジェクトを所有shared_ptrs数
    Original:
    the number of shared_ptrs that own the managed object
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 管理対象オブジェクトを参照してくださいweak_ptrs数
    Original:
    the number of weak_ptrs that refer to the managed object
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
shared_ptrを呼び出すことによって作成されたときにstd::make_sharedまたはstd::allocate_shared、制御ブロックは、データメンバとして、直接管理対象オブジェクトを保持しています。 shared_ptrはコンストラクタを呼び出すことによって作成されたときに、ポインタが格納されている.
Original:
When shared_ptr is created by calling std::make_shared or std::allocate_shared, the control block holds the managed object directly, as a data member. When shared_ptr is created by calling a constructor, a pointer is stored.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptrが保有するポインタが直接制御ブロックが保持しているポインタ/オブジェクトは、共有所有者の数がゼロになった時点で削除されるものである一方、get()で返されるものです:これらのポインターが必ずしも同じではありません.
Original:
The pointer held by the shared_ptr directly is the one returned by get(), while the pointer/object held by the control block is the one that will be deleted when the number of shared owners reaches zero: these pointers are not necessarily equal.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptrをデクリメントのデストラクタ制御ブロックの共有所有者の数、それがゼロに達すると、制御ブロックは、管理対象オブジェクトのデストラクタを呼び出しますが、std::weak_ptrカウンターだけでなくゼロに達するまで制御ブロックは、自分自身を解放していません.
Original:
The destructor of shared_ptr decrements the number of shared owners of the control block, and if that reaches zero, the control block calls the destructor of the managed object, but the control block does not deallocate itself until the std::weak_ptr counter reaches zero as well.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.