Skip to content
  • Mark OLESEN's avatar
    ENH: HashTable cfind() method returning a const_iterator · b8300759
    Mark OLESEN authored
    - This follows the same idea as cbegin/cend and is helpful when using
      C++11 auto to ensure we have unambiguous const-safe access.
    
      Previously:
      ====
        typename someLongClass::const_iterator iter = someTable.find(key);
    
        ... later on:
        *iter = value; // Oops, but caught by compiler.
    
      We can save some typing with auto, but it is uncertain what we get:
      ====
        auto iter = someTable.find(key);
            // iterator or const_iterator?
            // depends on someTable having const or non-const access.
    
        ... later on:
        *iter = value;  // Oops, but not caught by compiler.
    
      Using cfind instead, auto will deduce const_iterator as the type:
      ====
        auto iter = someTable.cfind(key);  // definitely const_iterator
    
        ... later on:
        *iter = value; // Oops, but caught by compiler.
    b8300759