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.
This commit is contained in:
Lei Zhang 2016-08-16 11:19:34 -04:00
parent 9747d33d08
commit b65124f097
2 changed files with 6 additions and 4 deletions

View File

@ -41,9 +41,10 @@ namespace ir {
// std::vector<|ValueType|>.
template <typename ValueType, bool IsConst = false>
class UptrVectorIterator
: public std::iterator<std::random_access_iterator_tag,
typename std::conditional<IsConst, const ValueType,
ValueType>::type> {
: public std::iterator<
std::random_access_iterator_tag,
typename std::conditional<IsConst, const ValueType, ValueType>::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<ValueType>;

View File

@ -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<uint32_t> binary;
module->ToBinary(&binary, /* skip_nop = */ false);