comp.lang.ada
 help / color / mirror / Atom feed
* Access conversions
@ 1998-10-12  0:00 Simon Wright
  1998-10-12  0:00 ` Tucker Taft
  1998-10-12  0:00 ` Matthew Heaney
  0 siblings, 2 replies; 4+ messages in thread
From: Simon Wright @ 1998-10-12  0:00 UTC (permalink / raw)


I need to write a function

  function Is_Member (G : Graph'Class; V : Vertex'Class) return Boolean;

where there is a type

  type Graph_Ptr is access all Graph'Class;

and a Vertex has a component Rep with a component Enclosing of type
Graph_Ptr which accesses its enclosing Graph.

In GNAT I can say in Is_Member

      return V.Rep.Enclosing = G'Unrestricted_Access;

but of course this isn't portable.

If I say

  function To_Ptr is new Ada.Unchecked_Conversion (System.Address,
                                                   Graph_Ptr);

and then in Is_Member

      return V.Rep.Enclosing = To_Ptr (G'Address);

which appears to work as expected in GNAT and ObjectAda 7.1, am I in
fact riding for a fall?

-Simon




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

end of thread, other threads:[~1998-10-13  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-12  0:00 Access conversions Simon Wright
1998-10-12  0:00 ` Tucker Taft
1998-10-13  0:00   ` Simon Wright
1998-10-12  0:00 ` Matthew Heaney

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