P
pauldepstein
I ran the following code which outputs two lines of text on the
screen. I can understand why the line x(); outputs a line of text
because that's the normal form of the overloaded call operator
operator()()
But it's puzzling to me why the lines boost::thread t((x)); t.join
(); also output a line of text on the screen.
To me the line boost::thread t((x)) doesn't seem to be applying the
overloaded call operator.
I would have thought that the overloaded call operator is implemented
via x(); or via x.operator();
I'd be grateful if someone could explain why boost::thread t((x));
apparently implements the overloaded call operator.
Thank you very much,
Paul Epstein
#include <boost\thread\thread.hpp>
#include <iostream>
class SayHello
{
public:
void operator()()
{
std::cout<<"I expected this line to occur once, not
twice!"<<std::endl;
}
};
int main()
{ SayHello x;
boost::thread t((x));
t.join();
x();
}
screen. I can understand why the line x(); outputs a line of text
because that's the normal form of the overloaded call operator
operator()()
But it's puzzling to me why the lines boost::thread t((x)); t.join
(); also output a line of text on the screen.
To me the line boost::thread t((x)) doesn't seem to be applying the
overloaded call operator.
I would have thought that the overloaded call operator is implemented
via x(); or via x.operator();
I'd be grateful if someone could explain why boost::thread t((x));
apparently implements the overloaded call operator.
Thank you very much,
Paul Epstein
#include <boost\thread\thread.hpp>
#include <iostream>
class SayHello
{
public:
void operator()()
{
std::cout<<"I expected this line to occur once, not
twice!"<<std::endl;
}
};
int main()
{ SayHello x;
boost::thread t((x));
t.join();
x();
}