<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2014-02-25 5:14 GMT-03:00 Sven Barth <span dir="ltr"><<a href="mailto:pascaldragon@googlemail.com" target="_blank">pascaldragon@googlemail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Am 25.02.2014 00:27, schrieb silvioprog:<div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hello,<br>
<br>
I have this structure:<br>
<br>
generic TMyGeneric<T> = class<br>
end;<br>
<br>
TMyGenericClass = class of TMyGeneric;<br>
</blockquote></div>
That must not compile. This is a bug.</blockquote><div><br></div><div>Can you issue it for me friend? I would be thankful. (y)</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
TMyType = class<br>
end;<br>
<br>
TMyClass1 = specialize TMyGeneric<TMyType>;<br>
<br>
TMyClass2 = class(specialize TMyGeneric<TMyType>)<br>
end;<br>
<br>
...<br>
<br>
procedure RegisterItem(AItemClass: TMyGenericClass);<br>
begin<br>
end;<br>
<br>
OK, but when I try:<br>
<br>
RegisterItem(TMyClass1);<br>
<br>
Return:<br>
<br>
Incompatible type for arg no. 1: Got "Class Of TMyGeneric$TMyType", expected "TMyGenericClass".<br>
<br>
Or:<br>
<br>
RegisterItem(TMyClass2);<br>
<br>
Return:<br>
<br>
Incompatible type for arg no. 1: Got "Class Of TMyClass2", expected "TMyGenericClass"<br>
<br>
So, which syntax to use generic and meta class?<br>
</blockquote></div>
You can't. A generic is by definition not a fully existant type. You can only work with specializations.<br>
E.g. TFPGList<> circumvents this by having the main implementation of the list inside a non generic TFPSList type which TFPGList<> derives from.<br>
<br>
Regards,<br>
Sven</blockquote><div><br></div><div>Thank for this nice information, I didn't know that.</div><div> </div></div>-- <br>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a>
</div></div>