iterators_0.2.0_18995a4d/deps/aaa/src/aaa-containers-indefinite_holders.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
with Ada.Finalization;

generic
   type Held (<>) is private;
package AAA.Containers.Indefinite_Holders with Preelaborate is

   --  Simple holder to work around GNAT holders bug

   type Holder is tagged private;

   procedure Clear (This : in out Holder);

   procedure Hold (This : in out Holder; Elem : Held);

   function To_Holder (Elem : Held) return Holder with
     Post => To_Holder'Result.Is_Valid;

   function Is_Empty (This : Holder) return Boolean;

   function Is_Valid (This : Holder) return Boolean is (not This.Is_Empty);

   function Element (This : Holder) return Held with
     Pre => This.Is_Valid;

   type Reference_Value (Element : access Held) is limited null record with
     Implicit_Dereference => Element;

   function Reference (This : in out Holder) return Reference_Value with
     Pre => This.Is_Valid;

   function Ref (This : in out Holder) return Reference_Value
                 renames Reference;

   function Unchecked_Reference (This : Holder) return access Held with
     Pre => This.Is_Valid;

   type Const_Ref_Value (Element : access constant Held) is limited null record
     with Implicit_Dereference => Element;

   function Get (This : Holder) return Const_Ref_Value with
     Pre => This.Is_Valid;

private

   type Held_Access is access all Held;

   type Holder is new Ada.Finalization.Controlled with record
      Item : Held_Access;
   end record;

   overriding
   procedure Adjust (This : in out Holder);

   overriding
   procedure Finalize (This : in out Holder);

end AAA.Containers.Indefinite_Holders;