If you have control over the input, and these strings are really supposed to represent bitmasks, then you probably want to keep them as integers of some sort and use bitmasks as suggested by others. Otherwise, if your stuck with dealing with them as strings, and you're going to use the same set of strings to search through multiple times, you're still better off converting them to integral bitmasks.
If, however, the set of strings is only being processed once, you're better off just going through the set and manually checking each once. Offhand, something like this:
int myfunc(set<string> in, string search){
assert(search.length() <= 32);
int result = 0;
for(set<string>::iterator iIn = in.begin(); iIn != in.end(); ++iIn)
{
bool isSubset = true;
if (iIn->length() != search.length()) // Is this guaranteed?
isSubset = false;
for (int iSearch = 0; isSubset && iSearch < search.length; ++iSearch)
if (search[iSearch] == '1' && (*iIn)[iSearch] == '0')
isSubset = false;
if (isSubset)
++result;
}
return result;
}
Or else the convert to long first version:
int myfunc(set<string> in, string search){
int result = 0;
long searchInteger = strtol(search.c_str(), NULL, 2);
for(set<string>::iterator iIn = in.begin(); iIn != in.end(); ++iIn)
if ((strtol(iIn->c_str(), NULL, 2) & searchInteger) == searchInteger)
++result;
return result;
}