Boost logo

Boost :

From: Greg Dehaas (GregDehaas_at_[hidden])
Date: 2003-02-07 02:43:54


Thanks, and yes, I am using MSVC (6)
Your answer makes sense, and it works fine!

That problem is a fairly irritating however
I'm suprised the bug fell through to MSVC7

-----Original Message-----
From: Craig Henderson [mailto:cdm.henderson_at_[hidden]]
Sent: Friday, February 07, 2003 12:32 AM
To: boost_at_[hidden]
Subject: [boost] Re: binding

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.

HTH
-- Craig

"Greg Dehaas" <GregDehaas_at_[hidden]> wrote in message
news:430AD3105AC1D511B8990010B5C225C710ACBC_at_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_at_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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk