struct count {
count(int id) : id(id) { }
void operator()() {
for (int i = 0; i < 10; ++i) {
boost::mutex::scoped_lock lock(io_mutex);
std::cout << id << ": " << i << std::endl;
}
}
int id;
};
This example came with no explanatory text. Not only are there advanced C++ goodies like initialization lists and functors, the guy uses the c++ idiom where same identifier is used for a formal parameter and a field variable. The compiler gives you a clever wink when you use code like
id(id) { }and sets the field "id" to the argument supplied in the constructor "id".
This example should have the comment
/* If you are reading this example, you are too ignorant to use my code. Go away. */
No comments:
Post a Comment