I would think both would accept function objects unless tr1::function<> is not the exact same thing as boost::bind (which I thought it was). Though I'd take the tr1::function by const reference instead of by value.
The first one allows more flexibility than the second because arguments can be bound via tr1::bind (ie, the actual signature of the called function can literally be anything as long as the tr1::bind() call is right). The second one mandates that the function take zero parameters.
void timeCount(std::tr1::function<void()> fc, std::string const& NAME = "")
this wouldn't work
besides, how could I pass arbitrary parameters to the std::tr1::function<void()> fc?
I try something like this
1 2 3 4 5 6 7 8 9 10 11
void hohoho(int a, int b)
{
}
void testTimeCount()
{
std::tr1::function<void(int, int)> i = std::tr1::bind(hohoho, 44, 88);
timeCount( i() ); //this wouldn't work
}
error: no match for call to '(std::tr1::function<void(int, int)>) ()
int add4( int a, int b, int c, int d )
{ return a + b + c + d; }
std::tr1::function<int(int,int)> add2 = std::tr1::bind( &add4, _1, _2, 0, 0 );
add2( 4, 7 ); // 11
std::tr1::function<void()> nothing = std::tr1::bind( &add4, 4, 7, 0, 0 );
timeCount(nothing); //should like this
timeCount(std::tr1::bind( &add4, 4, 7, 0, 0 )); //or like this
timeCount(nothing());//this one would cause error message