Create const overloads for begin() and end() in Instruction.

This commit is contained in:
Lei Zhang 2016-08-26 16:52:16 -04:00 committed by Lei Zhang
parent 923a4596b4
commit b1b2cac2cf
2 changed files with 3 additions and 2 deletions

View File

@ -123,6 +123,8 @@ class Instruction {
// Begin and end iterators for operands.
iterator begin() { return operands_.begin(); }
iterator end() { return operands_.end(); }
const_iterator begin() const { return operands_.cbegin(); }
const_iterator end() const { return operands_.cend(); }
// Const begin and end iterators for operands.
const_iterator cbegin() const { return operands_.cbegin(); }
const_iterator cend() const { return operands_.cend(); }

View File

@ -126,8 +126,7 @@ uint32_t Module::ComputeIdBound() const {
ForEachInst(
[&highest](const Instruction* inst) {
// Use a const-cast just to access begin() and end() for the range-for.
for (const auto& operand : *const_cast<Instruction*>(inst)) {
for (const auto& operand : *inst) {
if (spvIsIdType(operand.type)) {
highest = std::max(highest, operand.words[0]);
}