[xsd-users] use of auto_ptr

Guy Kroizman kroiz at hyperroll.com
Wed Apr 4 05:59:33 EDT 2007


why is it impossible to write exception-safe code using naked pointers?
As you suggested before, I could keep the naked pointer as a member in a
class the will destroy it in the destructor.
that is exception-safe. right?

On 4/4/07, Boris Kolpackov <boris at codesynthesis.com> wrote:
>
> Hi Guy,
>
> Guy Kroizman <kroiz at hyperroll.com> writes:
>
> I've CC'ed xsd-users to my reply. Please do the same in your future
> posts.
>
> > I would prefer to get a naked pointer and deciding my self how to
> > handle it.
>
> If we always returned naked pointers then it would be impossible to
> write exception-safe code using XSD. Because it is a common consensus
> that exception-safe code is a good thing, we cannot make this change
> just to satisfy a minority that does not care about exception safety.
>
> After all, it is just an extra call to release() to get rid of auto_ptr:
>
> foo_t* f = foo ("foo.xml").release ();
>
>
> [The rest of the original post follows for context.]
>
> > but I also understand the design consideration that since I did not
> > do "new" I could forget to delete it.
> > and by using auto_ptr I am receiving explicit ownership.
> > anyway thanks for the explanation.
>
>
> hth,
> -boris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.5 (GNU/Linux)
>
> iQGVAwUBRhNpwMiAKQuuCE8dAQKr6Av8C0H5J5SfBkDmclsuuv05pFxgQN8VUhhg
> qyvZNEh3NtsVx1QUHyjlkZOJFrLNSBtd3HWlifEm3VPYkg0DP6vLLHAT9mKMjIBq
> wTgI0YJMZj/e16swNbUJX5G/CYReC6/qunF6Q/kkEiUpaoI5tEqxtloAgexqtoqe
> 1TI3Go2Y75AQ2WU0E6lLZusDVSfzA9oamb44XVq0AWBLxrTESfagER5qQjOihzwt
> K5aBu8WzbEC+X+0iPLALkzQVY3PAOJwfdR6y2N3+SLbBDkT68O8mHLQMbg9/4VC9
> n91pssoLvEGFBpaEyIf+Cptswgdl73y5Tfa+Ow5jeg7vMazTZ7ctrmiX7RyEww+Q
> lrpzBp6fhwaEo2m+6QkGcjSPn263KxGo++bIFYL1Sx7K2HCixr3vnqfi4s9Gsa3L
> 9+jcvt88nmWzdCGp5Uo6SL8YHT/pW25YmCWRButtYuco4pQ1QQWhkMjXLs9TuJS+
> 29mK4dpPzan7S2GRUEUhq0nLnpRDTMbK
> =fI21
> -----END PGP SIGNATURE-----
>
>


-- 
Q: What do agnostic, insomniac dyslexics do at night?
A: Stay awake and wonder if there's a dog.



More information about the xsd-users mailing list