次の方法で共有


operator<< (<memory>)

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::shared_ptr<int> sp0(new int(5)); 
 
    std::cout << "sp0 == " << sp0 << " (varies)" << std::endl; 
 
    return (0); 
    } 
 
  

必要条件

ヘッダー : <memory>

名前空間: std

参照

関連項目

shared_ptr クラス

その他の技術情報

<memory> メンバー