Thread overview
Function Templates in DLL
Apr 01, 2008
Heinz
Apr 01, 2008
BCS
Apr 02, 2008
Robert Fraser
Apr 02, 2008
BCS
April 01, 2008
I think it has been asked before....can a function template be exported in a dll?
April 01, 2008
Heinz wrote:
> I think it has been asked before....can a function template be exported in a dll?

currently no.

theoretically....

If you were able to put a compiler in the DLL and serialize the parsed template then the only thing left over would be to suck out the type info from the calling code for the compiler....


Dang you! --> http://xkcd.com/356/
April 02, 2008
BCS wrote:
> Heinz wrote:
>> I think it has been asked before....can a function template be exported in a dll?
> 
> currently no.
> 
> theoretically....
> 
> If you were able to put a compiler in the DLL and serialize the parsed template then the only thing left over would be to suck out the type info from the calling code for the compiler....
> 
> 
> Dang you! --> http://xkcd.com/356/

Funny you mention that since that has been suggested and even worked out as a solution by Burton Radons:

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=11436
April 02, 2008
Robert Fraser wrote:
> BCS wrote:
> 
>> Heinz wrote:
>>
>>> I think it has been asked before....can a function template be exported in a dll?
>>
>>
>> currently no.
>>
>> theoretically....
>>
>> If you were able to put a compiler in the DLL and serialize the parsed template then the only thing left over would be to suck out the type info from the calling code for the compiler....
>>
>>
>> Dang you! --> http://xkcd.com/356/
> 
> 
> Funny you mention that since that has been suggested and even worked out as a solution by Burton Radons:
> 
> http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=11436 
> 

Almost, but not quite, I'm thinking more along the lines of thunk generation without the original code available. I'd "only" need access to the the symbol tables of the types the template accesses and some partially processed template code. Also rather than drop out an object file and then link that in, I'm thinking of actually compiling directly to RAM and then returning a function pointer. As I said, close, but not quite the same.