$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
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.