fork(2) download
  1. template < int head, int ... values >
  2. struct checker
  3. {
  4. static constexpr bool value(int i) noexcept
  5. { return i == head || checker<values...>::value(i); }
  6. };
  7.  
  8. template < int head >
  9. struct checker<head>
  10. {
  11. static constexpr bool value(int i) noexcept
  12. { return i == head; }
  13. };
  14.  
  15.  
  16. template< int ... values>
  17. constexpr bool check( int i ) noexcept
  18. {
  19. return checker<values...>::value(i);
  20. }
  21.  
  22.  
  23. int main() {
  24. static_assert(check<1, 2, 3>(2), "Bad true");
  25. static_assert(!check<4, 5, 6>(2), "Bad false");
  26. return 0;
  27. }
Success #stdin #stdout 0s 3336KB
stdin
Standard input is empty
stdout
Standard output is empty