◐ Shell
clean mode source ↗

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

来自cppreference.com

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 - 要向其插入 ptrstd::basic_ostream
ptr - 被插入到 os 的数据

返回值

os

示例

#include <iostream>
#include <memory>

class Foo {};

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

可能的输出:

参阅