Boost logo

Boost :

From: Spencer Collyer (spencer_at_[hidden])
Date: 2006-04-28 03:25:57


After our discussion I'm going to be adding runtime versions of my
existing compile-time bounds policies. I'll probably go with the design I
suggested, i.e. a public set_limits() that has to be called before any
element accesses, and that can only be called once.

On Thu, 27 Apr 2006 08:41:58 -0700, Sohail Somani wrote:
> > The option I came up with was to have a set_limit function on
> > the bounds
> > policy which you would call to define the limits at run time. The only
> > reason I haven't gone ahead and done the work to implement run-time
> > limits as yet is because I'm still not sure about the answers to a few
> > questions:
> I think you can have the sparse array implementation have an overloaded
> constructor that takes an instance of the policy. With a set_limit you
> may end up having invalid arrays for some length of time.

I think I see what you're getting at here, but given that the policies
are used through inheritance I'm not sure it is feasible in my class. I
imagine that the programmer will call the set_limits() function soon
after creating the sparse_array (indeed, probably the very next line),
but as long as it is before the first element access it should not be a
problem - there would, for instance, be nothing to stop you creating a
sparse_array and then passing it by reference to a function that
dynamically sets the size and then fills it.

> Then, I don't think there is anything stopping you from having a
> reset_bounds/resize type function, but I'd rather only have them be set
> once as you suggested.

For the reasons given in my original response to you I'm not keen to have
resizeable bounds. However, again, there is nothing to stop the
programmer writing their own bounds policy that allows this through a
public function, as long as they recognise any problems that may arise
with existing elements that have subscripts violating the policy.

I'm working to put together some pages on a web-site with documentation
and the current code for this class, so hopefully I'll have something to
show people soon. Unfortunately I have to go to a funeral today, so there
will be little done before tomorrow.


<<< Eagles may soar, but weasels don't get sucked into jet engines >>>
8:11am up 40 days 19:44, 23 users, load average: 0.16, 0.08, 0.06
Registered Linux User #232457 | LFS ID 11703

Boost list run by bdawes at, gregod at, cpdaniel at, john at