首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::shared_ptr::operator<<

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

?

?

插入shared_ptr<T>变成std::basic_ostream...

相当于os << ptr.get()...

参数

os

-

a std::basic_ostream to insert ptr into

ptr

-

the data to be inserted into os

返回值

os...

二次

代码语言:javascript
复制
#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;
}

二次

可能的产出:

二次

代码语言:javascript
复制
0x6d9028
0x6d9028

二次

另见

get

returns the stored pointer (public member function)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com