Yet an other remark but this time about the answer of Graig Henderson to Greg Dehass:
>>Greg, >>From the Linker Error, it looks like you're using Microsoft Visual C++. I >>discovered a bug recently with MSVC7.0 which may be the same as you're >>seeing here, but it is reported to be fixed in Everett. >> >>The bug occurs if you pass a template function as a parameter to another >>template function as a functor. The caller must specify the template >>parameters explicitly, and the functor is called without any knowledge of >>templates. However, if this is the only call to the functor with these >>template parameters, then the compiler fails togenerate code for the >>template and the linker fails with unresolved external. >>Try adding a separate call to the function GenAlg::RouletteWheel(class >>CGAController *) in a harmless piece of code to force the compiler to >>generate the templated code. You don't have to add a call to the function, that would be quite anoying to find a right place in your code to do so. What Greg should do is an explicit template instanciation writing this: template unsigned long GenAlg::RouletteWheel<CGAController, unsigned long>(CGAController*); This way, you function will be instanciated even if it is not call, and there is no more linking error. Best Regards "Greg Dehaas" <[EMAIL PROTECTED]> wrote in message 430AD3105AC1D511B8990010B5C225C710ACBC@DMISERVER01">news:430AD3105AC1D511B8990010B5C225C710ACBC@DMISERVER01... > Hi all, > > Could someone please tell me how to achieve a functor binding to a templated > function? > > I have a namespace GenAlg with this inside: > -------------------------------------------------------------------- > namespace GenAlg > { > template <class TController, class TFitness> > unsigned long RouletteWheel(TController *oController) > { > ... > } > } > -------------------------------------------------------------------- > > elsewhere I have a > -------------------------------------------------------------------- > boost::function1<unsigned long, CGAController *> fncSelection; > -------------------------------------------------------------------- > > I try to set fncSelection to RouletteWheel like so: > -------------------------------------------------------------------- > fncSelection = boost::bind(GenAlg::RouletteWheel<CGAController, unsigned > long>,_1); > -------------------------------------------------------------------- > > And my compiler's reply is: > -------------------------------------------------------------------- > genetics.obj : error LNK2001: unresolved external symbol "unsigned long > __cdecl GenAlg::RouletteWheel(class CGAController *)" > (?RouletteWheel@GenAlg@@YAKPAVCGAController@@@Z) > -------------------------------------------------------------------- > > Help? Please? > I'm sure this is stupid, simple stuff for you guys, and so annoying for me > :) > Greg > _______________________________________________ > Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost > _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost