comp.lang.ada
 help / color / mirror / Atom feed
From: "Peter C. Chapin" <pcc482719@gmail.com>
Subject: Vector of Vectors.
Date: Wed, 14 Jan 2009 19:32:25 -0500
Date: 2009-01-14T19:32:25-05:00	[thread overview]
Message-ID: <496e8418$0$25733$4d3efbfe@news.sover.net> (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



             reply	other threads:[~2009-01-15  0:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-15  0:32 Peter C. Chapin [this message]
2009-01-15  2:44 ` Vector of Vectors 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
replies disabled

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