|
Boost Users : |
From: Marshall Clow (marshall_at_[hidden])
Date: 2008-03-04 20:16:57
>Hi,
>
>Suppose I have the following code:
>
>template< typename T >
>void DoFoo( int number, T object )
>{
>}
>
>void main()
>{
> std::list<std::string> myStrings;
>
> // Assume myStrings is full of something...
>
> std::for_each( myStrings.begin(), myStrings.end(), boost::bind(
>&DoFoo, 5, _1 ) );
>}
>
>On MSVC 9, this will not compile because DoFoo is a template, and at
>some point, boost::bind can't take a template as the function to
>call, or it can't deduce the function's template arguments. Is there
>a way I can make this work? Thanks.
Would this work?
std::for_each( myStrings.begin(), myStrings.end(), boost::bind(
&DoFoo<std::string>, 5, _1 ) );
-- -- Marshall Marshall Clow Idio Software <mailto:marshall_at_[hidden]> It is by caffeine alone I set my mind in motion. It is by the beans of Java that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning. It is by caffeine alone I set my mind in motion.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net