shared_ptr_operator_ltlt
shared_ptr_operator_ltlt (shared_ptr 출력 연산자)
ptr에 저장된 포인터의 값을 출력 스트림 os에 삽입해요. os << ptr.get()과 동등해요.
출처: cppreference
본문
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_ostreamptr:os에 삽입할 데이터
반환값
os.
예제
#include <iostream>
#include <memory>
class Foo {};
int main()
{
auto sp = std::make_shared<Foo>();
std::cout << sp << '\n';
std::cout << sp.get() << '\n';
}
가능한 출력:
0x6d9028
0x6d9028
일반 출력 스트림에 shared_ptr을 직접 출력하면 저장된 포인터의 주소(16진수)가 나와요.