A.18.32 The Generic Package Containers.Bounded_Indefinite_Holders
The language-defined generic package Containers.Bounded_Indefinite_Holders
provides a private type Holder and a set of operations for that type.
It provides the same operations as the package Containers.Indefinite_Holders
(see
A.18.18), with the difference that
the maximum storage is bounded.
Static Semantics
The declaration of
the generic library package Containers.Bounded_Indefinite_Holders has
the same contents and semantics as Containers.Indefinite_Holders except:
The following is added to the context clause:
with System.Storage_Elements; use System.Storage_Elements;
An additional generic
parameter follows Element_Type:
Max_Element_Size_in_Storage_Elements : Storage_Count;
The
aspect_definition
for Preelaborable_Initialization for type Holder is changed to:
Preelaborable_Initialization =>
Element_Type'Preelaborable_Initialization
Add to the precondition
of To_Holder and Replace_Element:
and then (New_Item'Size <=
Max_Element_Size_in_Storage_Elements * System.Storage_Unit
or else raise Program_Error)
Bounded (Run-Time) Errors
It is a bounded error to assign
from a bounded holder object while tampering with elements of that object
is prohibited. Either Program_Error is raised by the assignment, execution
proceeds with the target object prohibiting tampering with elements,
or execution proceeds normally.
Implementation Requirements
For each instance of
Containers.Indefinite_Holders and each instance of Containers.Bounded_Indefinite_Holders,
if the two instances meet the following conditions, then the output generated
by the Holder'Output or Holder'Write subprograms of either instance shall
be readable by the Holder'Input or Holder'Read of the other instance,
respectively:
the Element_Type parameters of the two instances
are statically matching subtypes of the same type; and
the output generated by Element_Type'Output or
Element_Type'Write is readable by Element_Type'Input or Element_Type'Read,
respectively (where Element_Type denotes the type of the two actual Element_Type
parameters).
Implementation Advice
Bounded holder objects should be implemented without
dynamic allocation and any finalization should be trivial unless Element_Type
needs finalization.
The Implementation Advice about the Move and Swap
operations is deleted for bounded holders; these operations can copy
elements as necessary.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe