我的问题不是关于使用不区分大小写的 std::unordered_set ,而是它是如何工作的?
#include "stdafx.h"
#include <string>
#include <iostream>
#include <unordered_set>
#include "boost/algorithm/string.hpp"
struct case_insensitive_comparer
{
bool operator () (const std::string& x, const std::string& y) const
{
return boost::iequals(x, y);
}
};
using case_insensitive_set = std::unordered_set<std::string, std::hash<std::string>, case_insensitive_comparer>;
std::vector<std::string> permute_case(const std::string& s)
{
std::vector<std::string> strs;
// Iterate through all bitmasks, 1 for uppercase, 0 for lowercase
int msb = 1 << (s.length() - 1);
int upper = 1 << s.length();
std::locale loc;
for (int i = 0; i < upper; …
Run Code Online (Sandbox Code Playgroud)