Re: C++ question related to casting

From: Robert Collins <robertc@dont-contact.us>
Date: Wed, 24 May 2006 07:51:02 +1000

On Tue, 2006-05-23 at 21:40 +0200, Henrik Nordstrom wrote:
> tis 2006-05-23 klockan 15:01 -0400 skrev Nick Lewycky:
>
> > If possible, it should store the HttpHeaderEntry objects themselves
> > instead of pointers to them. Done properly, there shouldn't be any need
> > for a destructor at all.
>
> In this case there was a const barrier which needed to be penetrated,
> triggering all of this.. Probably a design error somewhere (missing
> write access method, or the code in question executing in the wrong
> context).
>
> > if not possible, then HttpHeader should either have an explicit copy
> > constructor which does the right thing, or else be non-copyable by
> > adding unimplemented private copy constructor and operator= . See
> > http://www.boost.org/boost/noncopyable.hpp for the technique.
>
> The latter I think here.. this kind of objects is best copied
> explicitly, and C++ is a bit too keen on making copy easy via the normal
> methods..

This is why, in our C++ guidelines we have 'always create copy
constructor and assignment operators - leave unimplemented if desired'.

:)

I'm not sure where they are now, but I remember discussing them way
back.

Rob

-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.

Received on Tue May 23 2006 - 16:51:37 MDT

This archive was generated by hypermail pre-2.1.9 : Thu Jun 01 2006 - 12:00:04 MDT