www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Function Templates in DLL

reply Heinz <malagana15 yahoo.es> writes:
I think it has been asked before....can a function template be exported in a
dll?
Apr 01 2008
parent reply BCS <BCS pathlink.com> writes:
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/
Apr 01 2008
parent reply Robert Fraser <fraserofthenight gmail.com> writes:
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
Apr 01 2008
parent BCS <BCS pathlink.com> writes:
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.annou ce&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.
Apr 02 2008