Boost logo

Boost Users :

From: Server Levent Yilmaz (leventyilmaz_at_[hidden])
Date: 2007-02-01 11:03:30


On 2/1/07, hongleij_at_[hidden] <hongleij_at_[hidden]> wrote:
>
> //my question is how to write the type ??? below to make it run .
>
> #include <boost/bind.hpp>
> #include <iostream>
> using boost::bind;
> void print()
> {
> std::cout <<" print" << std::endl;
> }
>
>
> template <class T>
> void func(T t)
> {
> std::cout <<"func1(T t) : " ;
> t();
> }
> int main()
> {
> func(bind(&print)); //ok

You don't have to use bind here.

func( print ) ;

would work.

    bind ( &func<???>, bind(&print) ) ; //don't know how to write it
> }

Note that this expression will not call anything, it will generate a functor
and drop it. I guess what you are trying to do is this

bind( func<void()>, print) (); // note the function call operator at the
end.

or maybe this:

bind( func<void()>, _1) (print);

hth,

-- 
Server Levent Yilmaz
Mechanical Engineering @ PITT


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