security+util: remove overloaded operator!()

Identity, Key, and EventId already provide an operator bool(),
which covers all valid use cases.

Change-Id: I57b11db6997e6f537873f41c6ca1c22140b894c3
diff --git a/src/security/pib/identity.cpp b/src/security/pib/identity.cpp
index 0f7dc26..3239ac3 100644
--- a/src/security/pib/identity.cpp
+++ b/src/security/pib/identity.cpp
@@ -83,13 +83,7 @@
 
 Identity::operator bool() const
 {
-  return !(this->operator!());
-}
-
-bool
-Identity::operator!() const
-{
-  return m_impl.expired();
+  return !m_impl.expired();
 }
 
 shared_ptr<detail::IdentityImpl>
diff --git a/src/security/pib/identity.hpp b/src/security/pib/identity.hpp
index 228ef16..7c9f714 100644
--- a/src/security/pib/identity.hpp
+++ b/src/security/pib/identity.hpp
@@ -97,18 +97,12 @@
   const Key&
   getDefaultKey() const;
 
-  /*
+  /**
    * @return True if the identity instance is valid
    */
   explicit
   operator bool() const;
 
-  /**
-   * @return True if the identity instance is invalid
-   */
-  bool
-  operator!() const;
-
 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // write operations should be private
   /**
    * @brief Add a @p key of @p keyLen bytes (in PKCS#8 format) with @p keyName.
diff --git a/src/security/pib/key.cpp b/src/security/pib/key.cpp
index 7396a5a..efb7df5 100644
--- a/src/security/pib/key.cpp
+++ b/src/security/pib/key.cpp
@@ -102,13 +102,7 @@
 
 Key::operator bool() const
 {
-  return !(this->operator!());
-}
-
-bool
-Key::operator!() const
-{
-  return m_impl.expired();
+  return !m_impl.expired();
 }
 
 shared_ptr<detail::KeyImpl>
diff --git a/src/security/pib/key.hpp b/src/security/pib/key.hpp
index fbbed24..b691960 100644
--- a/src/security/pib/key.hpp
+++ b/src/security/pib/key.hpp
@@ -77,7 +77,7 @@
   explicit
   Key(weak_ptr<detail::KeyImpl> impl);
 
-  /*
+  /**
    * @brief Get key name.
    */
   const Name&
@@ -128,12 +128,6 @@
   explicit
   operator bool() const;
 
-  /**
-   * @brief Check if the Key instance is invalid.
-   */
-  bool
-  operator!() const;
-
 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // write operations should be private
   /**
    * @brief Add @p certificate.
diff --git a/src/util/scheduler.cpp b/src/util/scheduler.cpp
index 8e72e78..3170f61 100644
--- a/src/util/scheduler.cpp
+++ b/src/util/scheduler.cpp
@@ -21,6 +21,7 @@
 
 #include "scheduler.hpp"
 #include "detail/monotonic-deadline-timer.hpp"
+
 #include <boost/scope_exit.hpp>
 
 namespace ndn {
@@ -50,10 +51,9 @@
   EventQueue::const_iterator queueIt;
 };
 
-bool
-EventId::operator!() const
+EventId::operator bool() const
 {
-  return m_info.expired() || m_info.lock()->isExpired;
+  return !m_info.expired() && !m_info.lock()->isExpired;
 }
 
 bool
diff --git a/src/util/scheduler.hpp b/src/util/scheduler.hpp
index 2393535..2139c76 100644
--- a/src/util/scheduler.hpp
+++ b/src/util/scheduler.hpp
@@ -23,8 +23,9 @@
 #define NDN_UTIL_SCHEDULER_HPP
 
 #include "time.hpp"
-#include <set>
+
 #include <boost/asio/io_service.hpp>
+#include <set>
 
 namespace ndn {
 namespace util {
@@ -64,17 +65,7 @@
    * \retval false This EventId is empty, or the event is expired or cancelled.
    */
   explicit
-  operator bool() const
-  {
-    return !this->operator!();
-  }
-
-  /**
-   * \retval true This EventId is empty, or the event is expired or cancelled.
-   * \retval false The event is valid.
-   */
-  bool
-  operator!() const;
+  operator bool() const;
 
   /**
    * \return whether this and other refer to the same event, or are both empty/expired/cancelled
diff --git a/tests/integrated/scheduler-benchmark.cpp b/tests/integrated/scheduler-benchmark.cpp
index 5fa57b7..5cc191e 100644
--- a/tests/integrated/scheduler-benchmark.cpp
+++ b/tests/integrated/scheduler-benchmark.cpp
@@ -28,6 +28,7 @@
 #include "boost-test.hpp"
 #include "timed-execute.hpp"
 
+#include <boost/asio/io_service.hpp>
 #include <iostream>
 
 namespace ndn {
@@ -42,17 +43,17 @@
   boost::asio::io_service io;
   Scheduler sched(io);
 
-  const int nEvents = 1000000;
+  const size_t nEvents = 1000000;
   std::vector<EventId> eventIds(nEvents);
 
   auto d1 = timedExecute([&] {
-    for (int i = 0; i < nEvents; ++i) {
+    for (size_t i = 0; i < nEvents; ++i) {
       eventIds[i] = sched.scheduleEvent(time::seconds(1), []{});
     }
   });
 
   auto d2 = timedExecute([&] {
-    for (int i = 0; i < nEvents; ++i) {
+    for (size_t i = 0; i < nEvents; ++i) {
       sched.cancelEvent(eventIds[i]);
     }
   });
@@ -66,8 +67,8 @@
   boost::asio::io_service io;
   Scheduler sched(io);
 
-  const int nEvents = 1000000;
-  int nExpired = 0;
+  const size_t nEvents = 1000000;
+  size_t nExpired = 0;
 
   // Events should expire at t1, but execution finishes at t2. The difference is the overhead.
   time::steady_clock::TimePoint t1 = time::steady_clock::now() + time::seconds(5);
@@ -79,7 +80,7 @@
     BOOST_REQUIRE_EQUAL(nExpired, nEvents);
   });
 
-  for (int i = 0; i < nEvents; ++i) {
+  for (size_t i = 0; i < nEvents; ++i) {
     sched.scheduleEvent(t1 - time::steady_clock::now(), [&] { ++nExpired; });
   }