Reputation: 4078
I just installed the last version of Visual Studio and I have this deque of tuple :
using InstancesOfOneObject = std::tuple<DrawCmd, std::deque<bool>, std::deque<glm::mat4>>;
std::deque<InstancesOfOneObject> mInstancesByObject;
After, I want to traverse this deque with a for ranged loop :
for (const auto &[cmd, validites, matrices] : mInstancesByObject)
However, that does not work, but :
for (const auto &instance : mInstancesByObject) {
const auto &[cmd, validities, matrices] = instance;
works well.
Is it normal? Is there a way to use something close to the first idea?
Upvotes: 0
Views: 365
Reputation: 303457
The only difference between:
for (const auto &[cmd, validites, matrices] : mInstancesByObject) { ... }
and:
for (const auto &instance : mInstancesByObject) {
const auto &[cmd, validities, matrices] = instance;
...
}
is that the latter allows you to still access instance
whereas in the former it's an unnamed object. They are otherwise equivalent. If the former doesn't compile, you should file a bug with that compiler.
Upvotes: 9