std::shared_ptr<T>::operator<<
来自cppreference.com
< cpp | memory | shared ptr
工具库
动态内存管理
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::shared_ptr
| 成员函数 | ||||
| 修改器 | ||||
| 观察器 | ||||
|
(C++17)
|
||||
|
(C++20
前)
|
||||
| 非成员函数 | ||||
|
(C++20
前)(C++20
前)(C++20
前)(C++20
前)(C++20
前)(C++20)
|
||||
|
operator<<
|
||||
|
函数(C++20
中弃用)
|
||||
| 辅助类 | ||||
|
(C++20)
|
||||
| 推导指引(C++17) |
|
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 << std::endl; std::cout << sp.get() << std::endl; }
可能的输出:
0x6d9028 0x6d9028
参阅
| 返回存储的指针 (公开成员函数) |