From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Access conversions
Date: 1998/10/12
Date: 1998-10-12T00:00:00+00:00 [thread overview]
Message-ID: <m37ly6vdqj.fsf@mheaney.ni.net> (raw)
In-Reply-To: x7v1zoe73ec.fsf@pogner.demon.co.uk
Simon Wright <simon@pogner.demon.co.uk> writes:
> 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
Instead of converting the address to an access type, and then comparing
access types, why not compare addresses directly:
return V.Rep.Enclosing.all'Address = G'Address;
Isn't this portable?
prev parent reply other threads:[~1998-10-12 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox