0
這個問題部分解答了這裏What does "typedef void (*Something)()" mean「typedef void(* task)()」是做什麼的?
但是答案並不完全清楚。
如果我寫
typedef void (*task)();
它是如何擴大?
thread_pool(unsigned int num_threads, task tbd) {
for(int i = 0; i < num_threads; ++i) {
the_pool.push_back(thread(tbd));
}
}
它會是這樣嗎?
thread_pool(unsigned int num_threads, (*task)() tbd) {
for(int i = 0; i < num_threads; ++i) {
the_pool.push_back(thread(tbd));
}
}
可能不是,因爲它是一個語法錯誤。我希望你能爲我解決問題。
代碼示例從http://www.thesaguaros.com/openmp-style-constructs-in-c11.html
謝謝,現在它是有道理的。 – 2013-02-09 12:47:36