Public 型 | Public メソッド
クラス テンプレート mist::weak_ptr< T >

参照カウント型のメモリに対する,弱参照を扱うポインタ [詳細]

#include <pointer.h>

mist::__shared_memory__::shared_base< T >を継承しています。

Public 型

typedef size_t size_type
 符号なしの整数を表す型.コンテナ内の要素数や,各要素を指定するときなどに利用し,内部的には size_t 型と同じ
typedef ptrdiff_t difference_type
 符号付きの整数を表す型.コンテナ内の要素数や,各要素を指定するときなどに利用し,内部的には ptrdiff_t 型と同じ
typedef T value_type
 内部データ型.T と同じ
typedef T * pointer
 データ型のポインター型.data の場合,data * となる
typedef T & reference
 データ型の参照.data の場合,data & となる
typedef const T & const_reference
 データ型の const 参照.data の場合,const data & となる
typedef const T * const_pointer
 データ型の const ポインター型.data の場合,const data * となる

Public メソッド

 weak_ptr ()
 未管理のポインタで初期化
 weak_ptr (shared_ptr< T > &p)
 共有メモリポインタの弱参照を用いて初期化する
 weak_ptr (const shared_ptr< T > &p)
 共有メモリポインタの弱参照を用いて初期化する
 weak_ptr (shared_array< T > &p)
 共有メモリ型の配列ポインタの弱参照を用いて初期化する
 weak_ptr (const shared_array< T > &p)
 共有メモリ型の配列ポインタの弱参照を用いて初期化する
 ~weak_ptr ()
 弱参照の参照カウントを1減らす
const weak_ptroperator= (const weak_ptr &p)
 他の共有メモリポインタを代入する
const weak_ptroperator= (const shared_ptr< T > &p)
 他の共有メモリポインタを代入する
const weak_ptroperator= (const shared_array< T > &p)
 他の共有メモリ型の配列ポインタを代入する
reference operator* ()
 ポインタが指す内容への参照を返す
const_reference operator* () const
 ポインタが指す内容への参照を返す
pointer operator-> ()
 ポインタが指す内容へのアクセスを行う
const_pointer operator-> () const
 ポインタが指す内容へのアクセスを行う
reference operator[] (difference_type index)
 配列の要素へのアクセスを行う
const_reference operator[] (difference_type index) const
 配列の要素へのアクセスを行う
void reset ()
 管理しているポインタの参照カウントを減らす
bool operator== (const weak_ptr &p) const
 2つのポインタが同一かどうかを判定する
bool operator!= (const weak_ptr &p) const
 2つのポインタが等しくないどうかを判定する
bool operator< (const weak_ptr &p) const
 2つのポインタの < を判定する
bool operator<= (const weak_ptr &p) const
 2つのポインタの <= を判定する
bool operator> (const weak_ptr &p) const
 2つのポインタの > を判定する
bool operator>= (const weak_ptr &p) const
 2つのポインタの >= を判定する
bool operator== (const pointer &p) const
 2つのポインタが同一かどうかを判定する
bool operator!= (const pointer &p) const
 2つのポインタが等しくないどうかを判定する
bool operator< (const pointer &p) const
 2つのポインタの < を判定する
bool operator<= (const pointer &p) const
 2つのポインタの <= を判定する
bool operator> (const pointer &p) const
 2つのポインタの > を判定する
bool operator>= (const pointer &p) const
 2つのポインタの >= を判定する

説明

template<class T>
class mist::weak_ptr< T >

参照カウント型のメモリに対する,弱参照を扱うポインタ

参照カウントが 0 にった際に,保持するポインタは NULL となる

注意
weak_ptr 自身は参照カウントを変化させない
弱参照ポインタの使用例
{
std::cout << a << std::endl; // <- a はどこも参照していないので NULL が入っている
{
mist::shared_ptr< std::string > b = new std::string[ 2 ];
a = b; // b の弱参照を a に設定する
std::cout << a << std::endl; // <- a は b を参照しているので b の参照先が表示される
} // <- ここで b に割り当てたメモリ領域がどこからも参照されなくなるため,メモリ領域が自動的に開放される
std::cout << a << std::endl; // <- a が参照していた b はもう存在しないので, NULL が入っている

関数

template<class T>
const weak_ptr& mist::weak_ptr< T >::operator= ( const weak_ptr< T > &  p)
inline

他の共有メモリポインタを代入する

注意
すでに管理しているポインタがある場合は,参照カウントを1減らす
その際に,どこからも参照されなくなったらメモリを開放する
template<class T>
const weak_ptr& mist::weak_ptr< T >::operator= ( const shared_ptr< T > &  p)
inline

他の共有メモリポインタを代入する

注意
すでに管理しているポインタがある場合は,参照カウントを1減らす
その際に,どこからも参照されなくなったらメモリを開放する
template<class T>
const weak_ptr& mist::weak_ptr< T >::operator= ( const shared_array< T > &  p)
inline

他の共有メモリ型の配列ポインタを代入する

注意
すでに管理しているポインタがある場合は,参照カウントを1減らす
その際に,どこからも参照されなくなったらメモリを開放する
template<class T>
void mist::weak_ptr< T >::reset ( )
inline

管理しているポインタの参照カウントを減らす

注意
どこからも参照されなくなったらメモリを開放する

このクラスの説明は次のファイルから生成されました:

Generated on Wed Nov 12 2014 19:44:28 for MIST by doxygen 1.8.1.2