Re: Access to function returning class-wide type
- From: Paweł 'Nivertius' Płazieński <nivertius@xxxxxxxxx>
- Date: Thu, 21 Aug 2008 13:56:35 +0200
Dmitry A. Kazakov wrote:
What I need is a access type to 'constructor' of an derivate of abstractSee Ada.Tags.Generic_Dispatching_Constructor. It gives you a function
object.
As I presented, there is a workaround, but that's not the 'right' way to
do it. I really want to do it without some tricky wrapping.
How do I define The_Access_Type to do what I want?
constructing an object from the type tag, the parameters (Natural in your
case) using the function you want (Proc). It goes as follows:
with Ada.Tags.Generic_Dispatching_Constructor;
package A is
type Abstracted is abstract tagged null record;
function Proc (N : not null access Natural)
return Abstracted is abstract;
function Constructor is
new Ada.Tags.Generic_Dispatching_Constructor
(Abstracted, Natural, Proc);
end A;
I belive that would work too, but at the cost of defining function Proc (N :
not null access Natural) return ... for each descendant type. That would be
another wrapper, so it's the same resolution to the problem as Proc_Wrapper
in my original code, assuming that I need Proc (N : Natural) as well.
Tell me that I'm wrong, please ;-)
--
Paweł Płazieński aka Nivertius
"In the end, there will be Ada, XML and gzip"
.
- Follow-Ups:
- Re: Access to function returning class-wide type
- From: Dmitry A. Kazakov
- Re: Access to function returning class-wide type
- References:
- Access to function returning class-wide type
- From: Paweł 'Nivertius' Płazieński
- Access to function returning class-wide type
- Prev by Date: Re: Status of ayacc and aflex?
- Next by Date: Re: Access to function returning class-wide type
- Previous by thread: Access to function returning class-wide type
- Next by thread: Re: Access to function returning class-wide type
- Index(es):
Relevant Pages
|