I recently had to write a function to return characters missing from an input string.  Here is the snippet#include <bitset>#include <string>template<class Iterator>std::string getMissingLetters(Iterator begin, Iterator end) {    std::bitset<26> letters;    for (auto it = begin; it != end; ++it) {        size_t c = tolower(*it) - char('a'); // normalized to start at 'a'        if (c > 26) continue;        letters.set(c);        if (letters.to_ulong() == ((1 << 26) - 1)) break;  // all 26 bits set    }    std::string missing;    for (int i = 0; i < letters.size(); ++i) {        if (!letters[i]) missing.push_back(char('a' + i));    }    return missing;}I thought of couple things to improve, for example avoiding branch by clamping characters, eg.letters.set(std::min(c, 26));and perhaps blocking the loop s.t. the lineif (letters.to_ulong() == ((1 << 26) - 1)) break;is executed every N iterations rather than each iteration.What do you think one could have done better?
Review of a C++ missing characters snippet
c++