title: Hash Table with vectors, getting error for retrieving size
body: <p>I am adding some code to functions where in the end I have a hash table that works for separate chaining. I am trying to retrieve the size of the hash table of all the non-deleted items in the hash, which is the function <code>int size()</code>
  This is the code that I think is relevant:</p>
  <pre><code> #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;list&gt;
  #include &lt;stdexcept&gt;
  
  // Custom project includes
  #include &quot;Hash.h&quot;
  
  // Namespaces to include
  using std::vector;
  using std::list;
  using std::pair;
  
  //
  // Separate chaining based hash table - inherits from Hash
  //
  template&lt;typename K, typename V&gt;
  class ChainingHash : public Hash&lt;K,V&gt; {
  
      int table_size;
  
  private:
      vector&lt;list&lt;V&gt;&gt; table;          // Vector of Linked lists
  
  public:
  
      ChainingHash(int n = 11) : table(n){
      
      }
  
      ~ChainingHash() {
          //this-&gt;clear();
      }
  
      //Test for empty hash
      bool empty() {
          
          if (!table.empty()) {
              return false;
          }
          
          return true;
    
      }
  
      //Quantity of (non-deleted) elements in hash
      int size() {
     
          int count = 0;
      
          for (int i = 0; i &lt; table.size(); i++) {
              if (table[i] != nullptr) {
                  count++;
              }
          }
          
          return count;
      
      }
      
  </code></pre>
  <p>I keep getting the error:</p>
  <pre><code>ChainingHash.h:65:20: error: no match for ‘operator!=’ (operand types are ‘__gnu_cxx::__alloc_traits&lt;std::allocator&lt;std::__cxx11::list&lt;int, std::allocator&lt;int&gt; &gt; &gt;, std::__cxx11::list&lt;int, std::allocator&lt;int&gt; &gt; &gt;::value_type’ {aka ‘std::__cxx11::list&lt;int, std::allocator&lt;int&gt; &gt;’} and ‘std::nullptr_t’)
     65 |       if (table[i] != nullptr) {
        |           ~~~~~~~~~^~~~~~~~~~
  In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                   from /usr/include/c++/9/memory:62,
                   from /usr/include/gtest/gtest.h:57,
                   from test_main.cpp:10:
  /usr/include/c++/9/bits/stl_pair.h:461:5: note: candidate: ‘template&lt;class _T1, class _T2&gt; constexpr bool std::operator!=(const std::pair&lt;_T1, _T2&gt;&amp;, const std::pair&lt;_T1, _T2&gt;&amp;)’
    461 |     operator!=(const pair&lt;_T1, _T2&gt;&amp; __x, const pair&lt;_T1, _T2&gt;&amp; __y)
        |     ^~~~~~~~
  </code></pre>
  <p>Can someone help me fix this?</p>