comp.lang.ada
 help / color / mirror / Atom feed
From: john@peppermind.com
Subject: Problem with indefinite discriminant records in container
Date: Tue, 5 Aug 2014 06:06:33 -0700 (PDT)
Date: 2014-08-05T06:06:33-07:00	[thread overview]
Message-ID: <986b5653-f446-4833-9a83-426f45b7c03f@googlegroups.com> (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?


             reply	other threads:[~2014-08-05 13:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-05 13:06 john [this message]
2014-08-05 16:05 ` Problem with indefinite discriminant records in container Simon Wright
2014-08-05 18:17   ` john
2014-08-06 10:58     ` G.B.
replies disabled

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