From b65124f097251ee150ba98b31d9ee6dbd08c624b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 16 Aug 2016 11:19:34 -0400 Subject: [PATCH] Make clear that we are using ptrdiff_t as the iterator difference type. And ptrdiff_t is a implementation defined signed type. Comparing it with unsigned number literal causes compiler warnings. --- source/opt/iterator.h | 8 +++++--- test/opt/test_ir_loader.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/opt/iterator.h b/source/opt/iterator.h index 6ca3dbc..da572ff 100644 --- a/source/opt/iterator.h +++ b/source/opt/iterator.h @@ -41,9 +41,10 @@ namespace ir { // std::vector<|ValueType|>. template class UptrVectorIterator - : public std::iterator::type> { + : public std::iterator< + std::random_access_iterator_tag, + typename std::conditional::type, + ptrdiff_t> { public: using super = std::iterator< std::random_access_iterator_tag, @@ -51,6 +52,7 @@ class UptrVectorIterator using pointer = typename super::pointer; using reference = typename super::reference; + using difference_type = typename super::difference_type; // Type aliases. We need to apply constness properly if |IsConst| is true. using Uptr = std::unique_ptr; diff --git a/test/opt/test_ir_loader.cpp b/test/opt/test_ir_loader.cpp index 8717140..479cb4b 100644 --- a/test/opt/test_ir_loader.cpp +++ b/test/opt/test_ir_loader.cpp @@ -216,7 +216,7 @@ TEST(IrBuilder, OpUndefOutsideFunction) { const auto opundef_count = std::count_if( module->types_values_begin(), module->types_values_end(), [](const ir::Instruction& inst) { return inst.opcode() == SpvOpUndef; }); - EXPECT_EQ(3u, opundef_count); + EXPECT_EQ(3, opundef_count); std::vector binary; module->ToBinary(&binary, /* skip_nop = */ false); -- 2.7.4