次の方法で共有


operator<< <memory>

更新 : 2007 年 11 月

shared_ptr の挿入演算子です。

template<class Elem, class Tr, class Ty>
    std::basic_ostream<Elem, Tr>& operator<<(std::basic_ostream<Elem, Tr>& out,
    shared_ptr<Ty>& sp);

パラメータ

  • Elem
    ストリーム要素の型。

  • Tr
    ストリーム要素の特徴の型

  • Ty
    共有ポインタによって制御される型。

  • out
    出力ストリーム。

  • sp
    共有ポインタ。

解説

このテンプレート関数は、out << sp.get() を返します。

使用例

 

// std_tr1__memory__operator_sl.cpp 
// compile with: /EHsc 
#include <memory> 
#include <iostream> 
 
int main() 
    { 
    std::tr1::shared_ptr<int> sp0(new int(5)); 
 
    std::cout << "sp0 == " << sp0 << " (varies)" << std::endl; 
 
    return (0); 
    } 
 
sp0 == 3f3040 (varies)

必要条件

ヘッダー : <memory>

名前空間 : std::tr1

参照

参照

<memory> (TR1)

shared_ptr クラス