I\'ve always been under the impression that for any comparison statement, i.e. X == Y
or X != Y
is the format, and you chain statements together with <
#include
#include
#include
#include
#include
template
bool is_one_of(const Type& needle, const Next& next)
{return needle==next;}
template
bool is_one_of(const Type& needle, const Next& next, Rest... haystack)
{return needle==next || is_one_of(needle, haystack...);}
int main() {
std::string X, Y;
if (is_one_of(X, Y, "HI"))
std::cout << "it is!";
else
std::cout << "it isn't!";
return 0;
}
proof of compilation. Xeo also observes that std::any_of
, std::all_of
and std::none_of
may have been useful, depending on your actual needs and desires.