|
Boost Users : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-11-03 13:24:58
Filipe Sousa wrote:
> int main()
> {
> {
> Connection c = ConnectionManager::instance()->connection();
> std::clog << "isConnected " << c.isConnected() << std::endl;
> c.connect();
This initializes the shared_ptr inside c, but has no effect on the
shared_ptr in the ConnectionManager map.
> std::clog << "isConnected " << c.isConnected() << std::endl;
std::clog << "isConnected " <<
ConnectionManager::instance()->connection().isConnected() << std::endl;
> }
'c' is destroyed here, along with its shared_ptr, which calls mysql_close.
> Connection c = ConnectionManager::instance()->connection();
> std::clog << "isConnected " << c.isConnected() << std::endl;
>
> return 0;
> }
You need to .reset( .. ) the shared_ptr in the map, before returning it from
the connection manager.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net