|
Boost : |
From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2001-01-11 10:33:33
wb_at_[hidden] wrote:
> in the C++ library. Therefore, I strongly favor this proposal, and
> respectfully recommend that the name "bounded" be applied to identify
> them:
>
> bounded_deque<myType> myDeque( MAX_NEEDED );
> bounded_queue<myType> myQueue( MAX_NEEDED );
> bounded_stack<myType> myStack( MAX_NEEDED );
> // ...
> myQueue.reserve( NEW_BOUND ); // if needed
>
> I prefer "bounded" to either "circular" or "wraparound" because it
> describes the external behavior; the other terms better describe some
> implementation details, knowledge of which would not materially help an
> average user.
Sounds good.
> At issue, perhaps, are such containers' behavior at the bound (i.e.,
> when "full"). There appear to be several useful possibilities:
>
> 1) Let the containers (silently) grow beyond the stated bound as
> needed. This mimics the unbounded containers' behavior.
>
> 2) Throw an exception under the theory that the user has violated
> his own bounds specification and it is useful to be so notified.
>
> 3) Let the policy (e.g., (1) or (2) above) be specified by the user
> via a member function or template argument or ....
>
> My own preference is for policy (2). I have two primary reasons for
I suggest not to introduce any policy at all, as both (any?) policy
would require the container to check the boundaries. Instead, I'd
suggest the usual STL approach and let the result be undefined
behaviour. A safe-STL could introduce some checks, but for performance
reasons the bounded containers shouldn't have this overhead.
Regards, Daniel
-- Daniel Frey wir machen anleger aixigo AG - financial research and education Schloß-Rahe-Straße 15, 52072 Aachen, Germany phone: +49 (0)241 93 67 37 - 42 fax: - 99 daniel.frey_at_[hidden] http://www.aixigo.de
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk