|
Boost : |
From: David B. Held (dheld_at_[hidden])
Date: 2002-09-23 14:11:11
"Howard Hinnant" <hinnant_at_[hidden]> wrote in message
news:705AEC29-CDC0-11D6-9E79-003065D18932_at_twcny.rr.com...
> [...]
> As for applications, I'm having a hard time believing that a scoped_ptr
> that only served the "current scope" intention would be useless. I
> agree that it might not be as widely used as a smart pointer capable of
> resource transfer, but I'm not convinced that it would be useless.
> [...]
It's not useless at all. For the three or four people in the world that use
the VCL, scope-limited smart pointers with no resource transfer are
very useful. That's because VCL objects can only be created on the
heap (because they're really Delphi objects, but that's another story).
A basic (VCL) example:
int foo(std::string const& name)
{
boost::scoped_ptr<TRegistry> reg(new TRegistry);
return reg->ReadInteger(name.c_str());
}
Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk