From cc351812b0109898a5d391ce21326de264d1443f Mon Sep 17 00:00:00 2001 From: Qing Zhang Date: Mon, 26 Oct 2020 14:00:47 -0700 Subject: [PATCH] add KV Table iterator bool operator --- libraries/eosiolib/contracts/eosio/key_value.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/eosiolib/contracts/eosio/key_value.hpp b/libraries/eosiolib/contracts/eosio/key_value.hpp index 375ebbf5d0..17b7debd75 100644 --- a/libraries/eosiolib/contracts/eosio/key_value.hpp +++ b/libraries/eosiolib/contracts/eosio/key_value.hpp @@ -444,6 +444,8 @@ namespace internal { return eosio::key_type{(char*)buffer, actual_value_size}; } + bool valid() const { return itr_stat == status::iterator_ok; } + protected: uint32_t itr; status itr_stat; @@ -569,6 +571,10 @@ class table : internal::table_base { bool operator>=(const iterator& b) const { return base_iterator::compare(b) >= 0; } + + explicit operator bool() const { + return this->valid(); + } }; class reverse_iterator : public base_iterator {