BOOST_FOREACH和矢量 [英] BOOST_FOREACH and a vector
本文介绍了BOOST_FOREACH和矢量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有场景的向量,矢量<&场景GT;
。什么是迭代的元素,作为参考或不正确的方法是什么?
例如对于这样的:
BOOST_FOREACH(场景一幕,mScenes)
{
.....
}
请问宏副本每次迭代在矢量场景,还是它在后台使用的参考?
那么,从这个有什么不同:
BOOST_FOREACH(场景和放大器;现场,mScenes)
{
.....
}
解决方案
BOOST_FOREACH
的行为完全为你告诉他,通过值,引用或常量引用
I have a vector of Scenes, vector<Scene>
. What is the correct way to iterate over the elements, as reference or not?
For example this:
BOOST_FOREACH(Scene scene, mScenes)
{
.....
}
Does the macro copy the Scene for each iteration over the vector, or does it use a reference behind the scenes?
So is it any different from this:
BOOST_FOREACH(Scene& scene, mScenes)
{
.....
}
解决方案
BOOST_FOREACH
behaves exactly as you tell him, by value, reference or const reference
这篇关于BOOST_FOREACH和矢量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文