const correctness [was: crasher fix]


Subject: const correctness [was: crasher fix]
From: Mike Nordell (tamlin@algonet.se)
Date: Tue May 15 2001 - 20:14:25 CDT


Patrick Lam wrote:
>
> On Tue, 15 May 2001, Mike Nordell wrote:
>
> > > void* getFirstItem() const;
> > > void* getLastItem() const;
> >
> > These are also errors. Either they should be non-const, or they should
> > return const pointers.
>
> I tried to make them const, but then ut_stack::pop gives a warning.
>
> bool UT_Stack::pop(void ** ppVoid)
>
> Would it be ok to make pop instead have the following signature:
>
> bool UT_Stack::pop(const void* & ppVoid)

No, since a pop operation transfer ownership of the resource. But it would
be OK to overload getFirst/last item with non-const versions.

/Mike



This archive was generated by hypermail 2b25 : Sat May 26 2001 - 03:51:04 CDT