将OpenMP与C ++ 11基于范围的for循环一起使用? [英] Using OpenMP with C++11 range-based for loops?

查看:76
本文介绍了将OpenMP与C ++ 11基于范围的for循环一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何反指示?还是对行为进行了明确规定?

Is there any counter-indication to doing this ? Or is the behavior well specified?

#pragma omp parallel for
for(auto x : stl_container)
{
   ...
}

因为似乎OpenMP规范仅对c ++ 98有效,但我猜可能由于C ++ 11线程而存在更多不兼容性,此处未使用.我还是想确定.

Because it seems that OpenMP specification is only valid for c++98 but I guess there might be more incompatibilities due to C++11 threads, which are not used here. I wanted to be sure, still.

推荐答案

OpenMP 5.0在第99页上添加了以下行,这使很多基于范围的for循环行!

OpenMP 5.0 adds the following line on page 99, which makes a lot of range-based for loops OK !

2.12.1.3具有随机访问迭代器的基于范围的for循环具有规范的循环形式.

2.12.1.3 A range-based for loop with random access iterator has a canonical loop form.

来源: https://www.openmp. org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf

这篇关于将OpenMP与C ++ 11基于范围的for循环一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆