这是一些简化的代码。它不是我的,但我正在将其改编为我的一个项目。它是我正在导入的庞大代码库的一部分,除了绝对必要之外,我不想对其进行更多更改。
void function (object& out_thing)
{
object thing;
#pragma omp nowait
for (int k = 0 ; k < 5 ; k++) {
object* things[2];
float scores[2];
for (i = 0; i < 2 ; i++)
scores[i] = evaluateThings(things[i], parameter1, parameter2);
if (scores[1] < scores[0]) {
scores[0] = scores[1];
things[0] = things[1];
}
thing = *(things[0]);
}
out_thing = thing;
}
Run Code Online (Sandbox Code Playgroud)
编译时,我收到警告,隐式声明的 thing = *(things[0]) 和 out_thing = thing 已弃用 [-Wdeprecated-copy] 因为我有一个用户提供的复制构造函数。
我猜编译器希望我写,object thing(*(things[1])但我不能写,因为我需要object thing在 omp …