comp.lang.ada
 help / color / mirror / Atom feed
From: Serge Robyns <serge.robyns@gmail.com>
Subject: Re: Design of cross referring types/classes and proper usage of containers
Date: Sat, 8 Aug 2015 04:25:45 -0700 (PDT)
Date: 2015-08-08T04:25:45-07:00	[thread overview]
Message-ID: <34d1bef3-5d7b-4420-8256-7227d5792a13@googlegroups.com> (raw)
In-Reply-To: <lyio8u3g2f.fsf@pushface.org>

As a follow-up on this discussion, I'm trying to have one of my containers containing the subscriptions but whereas I've a function returning the access to it in order to allow changes to it, through class procedures, not direct assignments.  This works if the container is storing access values, allocated through new T_Subscription.  When reading about Ada 2012 concept of of Reference_Type, I was trying to alter the container to store the T_Subscription without using access types.  However it does fail with compiler errors.

Here is the code snippet:

   package Subscription_Map is new Ada.Containers.Ordered_Maps (Key_Type     => T_Subscription_Name,
                                                                Element_Type => T_Subscription);


   Subscriptions          : aliased Subscription_Map.Map;

																
   function Get_Subscription
     (Subscription_Name : in T_Subscription_Name)
      return T_Subscription_Access is
      Cursor : Subscription_Map.Cursor;
   begin
      Cursor := Subscriptions.Find (Subscription_Name);
      if Cursor = Subscription_Map.No_Element then
         return null;
      else
         return T_Subscription_Access (Subscriptions.Reference (Cursor));
      end if;
   end Get_Subscription;

And the compiler moans on the return in the else part =>
ambiguous operand in conversion
possible interpretation at a-coorma.ads:104, instance at line 25
possible interpretation at a-coorma.ads:113, instance at line 25


  reply	other threads:[~2015-08-08 11:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-03 16:08 Design of cross referring types/classes and proper usage of containers Serge Robyns
2015-08-03 16:14 ` Serge Robyns
2015-08-03 20:17   ` Georg Bauhaus
2015-08-03 16:22 ` Dmitry A. Kazakov
2015-08-04 11:43   ` Serge Robyns
2015-08-04 12:13     ` Dmitry A. Kazakov
2015-08-04 19:00       ` Serge Robyns
2015-08-04 19:20         ` Jeffrey R. Carter
2015-08-04 20:27         ` Randy Brukardt
2015-08-04 21:21         ` Simon Wright
2015-08-08 11:25           ` Serge Robyns [this message]
2015-08-09  3:11             ` Randy Brukardt
2015-08-09 13:33               ` Serge Robyns
2015-08-05  7:37         ` Dmitry A. Kazakov
2015-08-05 17:51           ` Serge Robyns
2015-08-05 19:21             ` Dmitry A. Kazakov
2015-08-06  7:00               ` Georg Bauhaus
replies disabled

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