Testing whether characters of a string are unique
@Wayne Conrad has made some good points.  I just have a few additional ones:


I'm not sure about checking against a maximum value, but I'll address it anyway.

In case you'd like to change the default 256, consider having a template parameter.  That way, the value can be changed at just one location.  It'll also give more meaning to that value.

template &lt;std::size_t maxChars = 256&gt;
bool unique_chars(std::string &amp;s) {
    if (s.length() &gt; maxChars) return false;
    std::bitset&lt;maxChars&gt; bs;

    // ...
}

To slightly add on to Wayne's point about const, make sure the argument is const&amp; so that no unnecessary copying is done.  In addition, declaring the string argument as const will allow it to be passed in while avoiding casting.
Consider renaming the function to something like areUniqueChars().  Otherwise, it may sound like it's returning the number of unique chars.
In C++, prefer to put unary operators (such as &amp; and *) next to the type:

std::string&amp; s;




for (auto&amp; c : s) {}