◐ Shell
clean mode source ↗

std::shared_ptr<T>::operator<< - cppreference.com

提供: cppreference.com

<tbody> </tbody>

template <class T, class U, class V> std::basic_ostream<U, V>& operator<<(std::basic_ostream<U, V>& os, const std::shared_ptr<T>& ptr);

ptr に格納されているポインタの値を出力ストリーム os に挿入します。

os << ptr.get() と同等です。

引数

os - ptr を挿入する std::basic_ostream
ptr - os に挿入されるデータ

戻り値

os

#include <iostream>
#include <memory>

class Foo {};

int main()
{
    auto sp = std::make_shared<Foo>();
    std::cout << sp << '\n';
    std::cout << sp.get() << '\n';
}

出力例:

関連項目