Why does std :: shared_ptr provide a << operator?

std::shared_ptrprovides operator<<, which simply writes down its address. No operator>>and only the address without content is recorded. I am wondering in which cases this is useful.

+4
source share
1 answer

Because it is a potentially useful thing that it <<does on a raw pointer. This is safe, and this is what raw pointers do, and is shared_ptrintended to be used to replace the original pointers in some situations.

, >> . , .

some_stream >> raw_ptr, - ptr, . , .

shared_ptr . , , , .

0

Source: https://habr.com/ru/post/1672954/


All Articles