Object.factory

Sean Kelly sean at f4.ca
Wed Sep 26 07:42:57 PDT 2007


DanO wrote:
> BCS Wrote:
> 
>> Reply to DanO,
>>
>>
>>> MyDict!(int).classinfo.name == "MyDict!(int).MyDict";
>>> // Why the extra .MyDict appended to the end??
>>>
>> template are scopes. Thus this
>>
>> class Foo(t)
>> {
>> }
>>
>> is short hand for this
>>
>> template Foo(t)
>> {
>> class Foo
>> {
>> }
>> }
>>
>> and D lets you implicitly reference the only member of a template if it has 
>> the same name as the template it's self. However the correct name is the 
>> whole thing
> 
> I forgot about the whole shorthand thing...thanks for the refresher.
> 
> It still doesn't solve my problem.  It still can't seem to find a template class' ClassInfo via ClassInfo.find() or Object.factory().  Has anyone else seen this issue?  Thanks in advance.

You will need to generate the code for any template you want to generate 
via Object.factory by aliasing or instantiating it at compile-time. 
Otherwise, the code won't even exist in your app.  This should do the trick:

alias MyDict!(int) GenerateMyDict_int;


Sean



More information about the Digitalmars-d mailing list