What is the error in this Ada2012 program?
with Ada.Iterator_Interfaces; package My is type Cursor is private; function Has_Element (Position: Cursor) return Boolean; package Base_Iterators is new Ada.Iterator_Interfaces(Cursor, Has_Element); type Bindings_Iterator is new Base_Iterators.Forward_Iterator with private; overriding function First (Object: Bindings_Iterator) return Cursor; overriding function Next (Object: Bindings_Iterator; Position: Cursor) return Cursor; private type Iterated_Object is access all Integer; type Cursor is new Iterated_Object; type Bindings_Iterator is new Base_Iterators.Forward_Iterator with null record; end My; Attempt to check the syntax and semantics:
$ gnatgcc -gnat2012 -c my.ads my.ads:23:09: type must be declared abstract or "First" overridden my.ads:23:09: "First" has been inherited from subprogram at a-iteint.ads:26, instance at line 9 As far as I understand First is overridden by me. I don't get what the compiler complaints for.
access all, andallhere is because I access to an object which may be hold in a local variable not in a memory pool. So there is not need to deallocate it, as it is goes away when the local variable goes out of scope (this is the most likely use case of my code)