您好我想在全局声明一个boost线程并稍后对其进行初始化。 所以:
#include <iostream>
using namespace std;
boost::thread t;
void some_func()
{
printf("hello world\n");
}
int main()
{
t(some_func);
return 0;
}
它返回有关初始化的错误。
error: no match for call to ‘(boost::thread) (void (&)())
那我该怎么做呢?
编辑::我想这样做的原因是因为我想根据条件生成线程。所以在伪代码中:
if (cond A satisfied)
spawn thread_A
if (cond B satisfied)
spawn thread_B
// Do some stuff
if (cond B satisfied)
thread_B.join()
if (cond A satisfied)
thread_A.join()
如果线程没有全局范围,那么我就不能这样做
答案 0 :(得分:1)
<div class="overview-feature-1">
<div class="vehicleListing">1</div>
<div class="vehicleListing">2</div>
<div class="vehicleListing">3</div>
<div class="vehicleListing">4</div>
<div class="vehicleListing">5</div>
<div class="vehicleListing">6</div>
<div class="vehicleListing">7</div>
<div class="vehicleListing">8</div>
<div class="vehicleListing">9</div>
<div class="vehicleListing">10</div>
<div class="vehicleListing">11</div>
<div class="vehicleListing">12</div>
<div class="controls"></div>
<div class="additional-controls"></div>
</div>
的默认构造函数将对象初始化为没有活动线程。为了解决这个问题,您必须执行交换。
$(".vehicleListing").after().last().load('page2url' + ' .vehicleListing');
或来自rvalue的作业(在C ++ 11中):
t