[Q] does map.erase destroy shared_ptr ?
Hello, I am storing database streams as associated string tag as std::map< std::string, boost::shared_ptr<otl_stream> > once in a while I need to remove a stream based on the tag, so I do //find stream based on tag //close stream s->close //call map.erase can I expect that once I call map erase the destructor of the stream will get called? (for some reason I do not see my trace statement of the destructor, but the stream destruction are unfamiliar code to me.. so I may be just doing something wrong). thank you, Vlad -- V S P toreason@fastmail.fm -- http://www.fastmail.fm - Faster than the air-speed velocity of an unladen european swallow
AMDG V S P wrote:
I am storing database streams as associated string tag as std::map< std::string, boost::shared_ptr<otl_stream> >
once in a while I need to remove a stream based on the tag,
so I do
//find stream based on tag //close stream s->close //call map.erase
can I expect that once I call map erase the destructor of the stream will get called?
You can expect the shared_ptr to be destroyed. Whether the stream is destroyed depends on whether there are any other shared_ptrs to it.
(for some reason I do not see my trace statement of the destructor, but the stream destruction are unfamiliar code to me.. so I may be just doing something wrong).
In Christ, Steven Watanabe
participants (2)
-
Steven Watanabe
-
V S P