将所有常量添加到std :: set,然后您可以检查该集合是否包含您的字符串
std::set<std::string> myLookup;
//populate the set with your strings here
set<std::string>::size_type i;
i = myLookup.count(searchTerm);
if( i )
std::cout << "Found";
else
std::cout << "Not found";
Run Code Online (Sandbox Code Playgroud)