comp.lang.ada
 help / color / mirror / Atom feed
* Vector of Vectors.
@ 2009-01-15  0:32 Peter C. Chapin
  2009-01-15  2:44 ` Jeffrey R. Carter
  0 siblings, 1 reply; 22+ messages in thread
From: Peter C. Chapin @ 2009-01-15  0:32 UTC (permalink / raw)


I'm having a bit of trouble manipulating an element of a vector of
vectors. I'm using GNAT GPL 2008. Here is a small program to illustrate
the issue:

with Ada.Containers.Vectors;

procedure Check is
   package Integer_Vectors is
      new Ada.Containers.Vectors
         (Index_Type   => Natural,
          Element_Type => Integer);

   package Nested_Vectors is
      new Ada.Containers.Vectors
         (Index_Type   => Natural,
          Element_Type => Integer_Vectors.Vector,
          "="          => Integer_Vectors."=");

   IV : Integer_Vectors.Vector;
   NV : Nested_Vectors.Vector;
begin
   IV.Append(42);
   NV.Append(IV);
   NV.Element(0).Append(43);  -- Compile error here.
end Check;

The error message is, "Actual for Container must be a variable." I
understand what this means. The problem is that I'm trying to use an
expression as an argument for an 'in out' parameter. What I'm having
trouble figuring out is how to work around this. I tried using 'renames'
to give a simple name to NV.Element(0) but that didn't fool the compiler
(no surprise). I also tried playing around with anonymous access types
but I couldn't figure out how to declare the Element_Type of package
Nested_Vectors to be aliased. I'm not sure if it would have worked in
any case.

Surely there must be a straight forward way to do this!

Peter



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

end of thread, other threads:[~2009-01-20  2:11 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-15  0:32 Vector of Vectors Peter C. Chapin
2009-01-15  2:44 ` Jeffrey R. Carter
2009-01-15 10:10   ` Alex R. Mosteo
2009-01-15 10:56     ` Georg Bauhaus
2009-01-15 20:44     ` Jeffrey R. Carter
2009-01-15 21:26       ` Robert A Duff
2009-01-17 10:20         ` Ivan Levashew
2009-01-17 10:51           ` Dmitry A. Kazakov
2009-01-17 16:45             ` Robert A Duff
2009-01-17 17:18               ` Dmitry A. Kazakov
2009-01-17 23:06                 ` Robert A Duff
2009-01-18  9:44                   ` Dmitry A. Kazakov
2009-01-17 16:41           ` Robert A Duff
2009-01-17 18:56             ` Georg Bauhaus
2009-01-17 22:59               ` Robert A Duff
2009-01-18 18:34                 ` Georg Bauhaus
2009-01-18 21:29                   ` Robert A Duff
2009-01-19 11:52                     ` Georg Bauhaus
2009-01-19 12:39                       ` Georg Bauhaus
2009-01-20  2:11                     ` Randy Brukardt
2009-01-15 12:08   ` Peter C. Chapin
2009-01-16 10:15     ` Alex R. Mosteo

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