Next: Aspect Linker_Section, Previous: Aspect Invariant'Class, Up: Implementation Defined Aspects [Contents][Index]
This aspect provides a light-weight mechanism for loops and quantified expressions over container types, without the overhead imposed by the tampering checks of standard Ada 2012 iterators. The value of the aspect is an aggregate with four named components: First, Next, Has_Element, and Element (the last one being optional). When only 3 components are specified, only the for .. in form of iteration over cursors is available. When all 4 components are specified, both this form and the for .. of form of iteration over elements are available. The following is a typical example of use:
type List is private with Iterable => (First => First_Cursor, Next => Advance, Has_Element => Cursor_Has_Element, [Element => Get_Element]);
function First_Cursor (Cont : Container) return Cursor;
function Advance (Cont : Container; Position : Cursor) return Cursor;
function Cursor_Has_Element (Cont : Container; Position : Cursor) return Boolean;
function Get_Element (Cont : Container; Position : Cursor) return Element_Type;
This aspect is used in the GNAT-defined formal container packages.
Next: Aspect Linker_Section, Previous: Aspect Invariant'Class, Up: Implementation Defined Aspects [Contents][Index]