iterators_0.2.0_18995a4d/src/iterators-from-elements-lists.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
58
59
60
61
62
63
64
65
66
67
68
69
with Ada.Containers.Indefinite_Doubly_Linked_Lists;

with Iterators.Collectors.Sequences;
with Iterators.Generators.Containers;
with Iterators.Traits.Containers.Appendable;

generic
package Iterators.From.Elements.Lists with Preelaborate is

   package Ada_Containers is new
     Ada.Containers.Indefinite_Doubly_Linked_Lists (Any_Element);

   subtype Container is Ada_Containers.List;

   --  Bug work-arounding:

   type Reference_Type
     (Element : not null access Any_Element) is
     new Ada_Containers.Reference_Type (Element => Element);

   function Reference
     (C : aliased in out Container;
      P : Ada_Containers.Cursor) return Reference_Type is
     (Reference_Type
        (Ada_Containers.Reference_Type'
             (Ada_Containers.Reference (C, P))));

   type Constant_Reference_Type
     (Element : not null access constant Any_Element) Is
   new Ada_Containers.Constant_Reference_Type (Element => Element);

   function Constant_Reference
     (C : aliased Container;
      P : Ada_Containers.Cursor) return Constant_Reference_Type is
     (Constant_Reference_Type
        (Ada_Containers.Constant_Reference_Type'
             (Ada_Containers.Constant_Reference (C, P))));

   --  Resume normal operation

   package Container_Traits is new Traits.Containers
     (Container                   => Container,
      Element_Type                => Any_Element,
      Cursor                      => Ada_Containers.Cursor,
      First                       => Ada_Containers.First,
      Next                        => Ada_Containers.Next,
      Has_Element                 => Ada_Containers.Has_Element,
      Reference_Type              => Reference_Type,
      Reference                   => Reference,
      Constant_Reference_Type     => Constant_Reference_Type,
      Constant_Reference          => Constant_Reference);

   package Appendable_Traits is new Container_Traits.Appendable
     (Ada_Containers.Append);

   package Collectors is new Standard.Iterators.Collectors.Sequences
     (Iterators,
      Container_Traits,
      Appendable_Traits);
   package Col renames Collectors;

   package Generators is new Standard.Iterators.Generators.Containers
     (Iterators,
      Container_Traits);
   package Gen renames Generators;

   package Linking renames Collectors.Linking;

end Iterators.From.Elements.Lists;