#include <stdio.h>
const char chars[] = {'a', 'b', 'c', 'd', 'e', 'f'};
template<class T>
bool memberOf(T x, const T elems[])
{
printf("sizeof(elems) == %d\n", sizeof(elems));
for(int i = 0;i < sizeof(elems); ++i) {
if (x == elems[i])
return true;
}
return false;
}
int main(int argc, char* argv[])
{
if (memberOf('f', chars)) {
printf("found!!\n");
} else {
printf("not found.\n");
}
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiAKY29uc3QgY2hhciBjaGFyc1tdID0geydhJywgJ2InLCAnYycsICdkJywgJ2UnLCAnZid9OwogCnRlbXBsYXRlPGNsYXNzIFQ+IApib29sIG1lbWJlck9mKFQgeCwgY29uc3QgVCBlbGVtc1tdKSAKewogICAgICAgIHByaW50Zigic2l6ZW9mKGVsZW1zKSA9PSAlZFxuIiwgc2l6ZW9mKGVsZW1zKSk7CiAgICAgICAgZm9yKGludCBpID0gMDtpIDwgc2l6ZW9mKGVsZW1zKTsgKytpKSB7CiAgICAgICAgICAgICAgICBpZiAoeCA9PSBlbGVtc1tpXSkgCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICByZXR1cm4gZmFsc2U7Cn0KIAppbnQgbWFpbihpbnQgYXJnYywgY2hhciogYXJndltdKQp7CiAgICBpZiAobWVtYmVyT2YoJ2YnLCBjaGFycykpIHsKICAgICAgICAgICAgcHJpbnRmKCJmb3VuZCEhXG4iKTsKICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHByaW50Zigibm90IGZvdW5kLlxuIik7IAogICAgfQp9