Hi,
I am getting some weird behaviour with range-based for loop in C++11 with Urho3D containers. It looks like undefined behaviour as sometimes I am getting a crash and sometimes I am not. I hope I am not doing it completely wrong. As far as I remember this should work with STL containers and smart pointers.
This is a simple example:
[code]SharedPtr particleEmitter1_;
SharedPtr particleEmitter2_;
particleEmitter1_ = particleNode_->CreateComponent();
particleEmitter1_->SetEffect(particleEffect1_);
particleEmitter2_ = particleNode_->CreateComponent();
particleEmitter2_->SetEffect(particleEffect2_);
Vector<SharedPtr> particleEmitters_;
particleEmitters_.Push(particleEmitter1_);
particleEmitters_.Push(particleEmitter2_);
for (auto particleEmitter : particleEmitters_)
{
particleEmitter->SetEmit(false);
}
[/code]