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
...
例
二次
#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;
}
二次
可能的产出:
二次
0x6d9028
0x6d9028
二次
另见
get | returns the stored pointer (public member function) |
---|
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com