#include template bool all_of_checks(const int& value, const Checks&... checks) { return (... && static_cast(checks(value))); } int main() { assert(all_of_checks(7)); const auto positive = [](int n) { return n > 0; }; const auto even = [](int n) { return n % 2 == 0; }; assert(all_of_checks(8, positive, even)); assert(!all_of_checks(3, positive, even)); int calls = 0; const auto reject = [&calls](int) { ++calls; return false; }; const auto expensive = [&calls](int) { calls += 100; return true; }; const bool accepted = all_of_checks(8, reject, expensive); assert(!accepted); assert(calls == 1); }