Boost logo

Boost :

From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2000-12-04 12:11:14


> > [Gary Powell]
> > in pool.h
> >
> > ~pool()
> > I dislike
> > if (list.begin() == 0)
> >
> > It breaks what I think of as the iterator concept. If what is meant is
> > if (list.uninitialized() )
> >
> > or
> > if (list.empty() )
> >
> > that should be used instead.
>
> Before submitting pool, I toyed around with a more advanced
> "iterator"-style
> approach to the implementation, using iterator classes both for the
> interleaved free list and for the list of memory blocks. However, I found
> that it was much more trouble than it's worth; the only benefit is
> implementation code that is a little cleaner in some places, and much more
> complicated in others. So I dropped that idea.
>
Ok, but what you have is not clear at all. So how about a couple of trivial
member functions that indicate the nature of the statement. list.begin() ==
0 is one of those "magic" number statements whose meaning rapidly becomes
lost in time.

> > [Gary Powell]
> > class PODptr should have a default constructor, rather than hide the
> > default data in sized_pool. (It's partly stylistic but when you use a
> value
> > as an indicator of uninitialized IMO it should be done all within the
> class,
> > and not by the calling class.)
>
>> snip <<

> The PODptr in sized_pool is not the default data, but rather the "pointer"
> to the first memory block in the memory block list for that sized_pool.
>
I think you missed understood my complaint. It's not the what PODptr is
that's the complaint, its that you are again using the magic "0" to have a
special meaning. And its meaning is known by PODptr and sized_pool, when it
could be known only to POPptr. (Containment and Isolation of magic numbers.)

Thanks for the standard reference on < >= etc. I knew you wouldn't have used
the unwieldy less and less_equal unless there was a good reason.

  -gary-


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk