std::shared...::operator<<(3)
πΈ NAME πΈ
std::shared_ptr::operator<< β std::shared_ptr::operator<< π
okay so this is the C++ Standard Libary manual page for the stream-insertion operator that works with std::shared_ptr, and it's literally here to help you understand what happens when you send one into an output stream β¨
β¨ Synopsis β¨
bestie, here's the signature β keep it exact, no cap:
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 );
what it does: it inserts the value of the pointer stored in ptr into the output stream os π«Ά
it's equivalent to os << ptr.get() β periodt π
π Parameters π
osβ astd::basic_ostreamto insertptrintoptrβ the data to be inserted intoos
π Return value π
it returns os π
π¦ Example π¦
run this code, it's giving shared-pointer-in-a-stream realness:
// Run this code
#include <iostream>
#include <memory>
class Foo {};
int main()
{
auto sp = std::make_shared<Foo>();
std::cout << sp << '\n';
std::cout << sp.get() << '\n';
}
π Possible output π
0x6d9028
0x6d9028
π See also π
getβ returns the stored pointer (public member function)
source/version + date check bestie: http://cppreference.com Β· 2024.06.10 Β· std::shared...::operator<<(3) β periodt, mwah ππ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms