Yes, I am using MSVC - I guess that would be an important piece of information to include.  Are there any slick tricks here, or do I have to actually make a call to the template function at some point other than for_each?

Thanks!

-----Original Message-----
From: Gennadiy E. Rozental [mailto:rogeeff@mail.com]
Sent: Monday, October 22, 2001 11:22 AM
To: boost@yahoogroups.com
Subject: [boost] Re: bind, template functions, and the linker


What compiler ar you using? If it MSVC it's appears to be known issue
and usin gtemporary could help.

--- In boost@y..., brownell@a... wrote:
> I don't think this is a problem with bind, but more of a C++ issue,
> so my apologies if this is a bit off topic.  I am passing a
template
> function to bind, and the resulting "bound" function is used as the
> UnaryFunction in std::for_each.  When I compile this application,
> everything works as expected, but when the linker does its thing,
it
> can't find the template function.  If I make a dummy call to the
> template function, the function code is created and the linker is
> happy.  Is there a way I can make this all work without the dummy
> call to the template function?  I have a code example illustrating
> the problem below.
>
> Thanks in advance for your help!
> Dave
>
> #include<vector>
> #include<algorithm>
>
> #include "boost\bind.hpp"
>
> template<class T>
> bool TemplateFunction(T &t)
> {
>     t = 2;
>     return(true);
> }
>
> int main(void)
> {
>     std::vector<unsigned long>          v;
>
>     v.resize(10);
>
>     //If this code segment is commented, it will not link.
Uncomment
>     //  to resolve the link error
>     /*{
>         unsigned long       ulTemp;
>
>         TemplateFunction(ulTemp);
>     }*/
>
    bool (*temp)( unsigned long& ) = &TemplateFunction<unsigned long>;

     std::for_each(v.begin(), v.end(), boost::bind(temp, _1));
     return(1);
> }


Info: http://www.boost.org  Unsubscribe: <mailto:boost-unsubscribe@yahoogroups.com>

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/