Languages for servers (Go, D, and more)
Brad Anderson via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jul 8 11:04:12 PDT 2014
On Tuesday, 8 July 2014 at 17:55:15 UTC, Sean Kelly wrote:
>
> Well sure, but you can't use a class instance living on the
> stack
> as the context for a callback. At that point, whatever smart
> pointer you're using has to be discarded. This is actually why
> I
> find little use for std::shared_ptr--it has unique() and get()
> but no release() (which makes me wonder why they even bothered
> to
> offer unique()). It's kind of sad that the intended goal of not
> using raw pointers is actually forcing me to use raw pointers.
> In practice, I either use auto_ptr (now unique_ptr) for
> exception
> safety and release when passing to a function with a callback
> (in
> keeping with modern C++ idioms), or in containers and such I use
> my own shared_ptr that provides a release() function which fails
> if unique() is false.
Maybe I'm misunderstanding but why not just use reset()?
More information about the Digitalmars-d
mailing list