comp.lang.ada
 help / color / mirror / Atom feed
* Problem with indefinite discriminant records in container
@ 2014-08-05 13:06 john
  2014-08-05 16:05 ` Simon Wright
  0 siblings, 1 reply; 4+ messages in thread
From: john @ 2014-08-05 13:06 UTC (permalink / raw)


I want to store records of different size in Ada.Containers.Indefinite_Vectors:

 type Rt_Class (Method_Table_Size : MethodId;
                  Superclass_Count  : ClassId) is record
      Id              : ClassId;
      Is_Interface    : Boolean;
      Methods         : Rt_Methods (1 .. Method_Table_Size);
      Superclasses    : Rt_Class_Ids (1 .. Superclass_Count);
      Inst_Prop_Count : Natural;
      Method_Count    : Natural;
   end record;

   package Class_Vectors is new Ada.Containers.Indefinite_Vectors
     (Index_Type => ClassId,
      Element_Type => Rt_Class);
   use Class_Vectors;
   type Rt_Classes is new Class_Vectors.Vector with null record;

it compiles but I get a *runtime* error "instantiation error" with explanation 
"invalid constraint: type has no discriminant" when the above package is instantiated.

Rt_Methods and Rt_Class_Ids are array types and all of this occurs in the private part of a package. 

How can I store different versions of an indefinite record with discriminants such as Rt_Class in some array or vector? Using access types would be very hard if not impossible in this case because of the associated scope restrictions. Somewhat annoying in this case is also that this table/array only needs to be created *once* in the beginning of program execution and otherwise is completely static and read-only ... and access should be as fast as possible.

Any ideas or suggestions?


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-06 10:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-05 13:06 Problem with indefinite discriminant records in container john
2014-08-05 16:05 ` Simon Wright
2014-08-05 18:17   ` john
2014-08-06 10:58     ` G.B.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox