template < int head, int ... values >
struct checker
{
static constexpr bool value(int i) noexcept
{ return i == head || checker<values...>::value(i); }
};
template < int head >
struct checker<head>
{
static constexpr bool value(int i) noexcept
{ return i == head; }
};
template< int ... values>
constexpr bool check( int i ) noexcept
{
return checker<values...>::value(i);
}
int main() {
static_assert(check<1, 2, 3>(2), "Bad true");
static_assert(!check<4, 5, 6>(2), "Bad false");
return 0;
}
dGVtcGxhdGUgPCBpbnQgaGVhZCwgaW50IC4uLiB2YWx1ZXMgPgpzdHJ1Y3QgY2hlY2tlcgp7CiAgc3RhdGljIGNvbnN0ZXhwciBib29sIHZhbHVlKGludCBpKSBub2V4Y2VwdAogIHsgcmV0dXJuIGkgPT0gaGVhZCB8fCBjaGVja2VyPHZhbHVlcy4uLj46OnZhbHVlKGkpOyB9Cn07Cgp0ZW1wbGF0ZSA8IGludCBoZWFkID4Kc3RydWN0IGNoZWNrZXI8aGVhZD4KewogIHN0YXRpYyBjb25zdGV4cHIgYm9vbCB2YWx1ZShpbnQgaSkgbm9leGNlcHQKICB7IHJldHVybiBpID09IGhlYWQ7IH0KfTsKCgp0ZW1wbGF0ZTwgaW50IC4uLiB2YWx1ZXM+IApjb25zdGV4cHIgYm9vbCBjaGVjayggaW50IGkgKSBub2V4Y2VwdAp7CiAgcmV0dXJuIGNoZWNrZXI8dmFsdWVzLi4uPjo6dmFsdWUoaSk7Cn0KCgppbnQgbWFpbigpIHsKCXN0YXRpY19hc3NlcnQoY2hlY2s8MSwgMiwgMz4oMiksICJCYWQgdHJ1ZSIpOwoJc3RhdGljX2Fzc2VydCghY2hlY2s8NCwgNSwgNj4oMiksICJCYWQgZmFsc2UiKTsKCXJldHVybiAwOwp9