fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template<typename T, typename U>
  6. bool isOneOf(T a, U b) {
  7. return a == b;
  8. }
  9.  
  10. template<typename T, typename U, typename ... Args>
  11. bool isOneOf(T a, U b, Args ... args) {
  12. return isOneOf(a, b) || isOneOf(a, args...);
  13. }
  14.  
  15. class Checker {
  16. int checks;
  17. int value;
  18. public:
  19. Checker(int value) {
  20. this->checks = 0;
  21. this->value = value;
  22. }
  23. int getValue() {
  24. checks += 1;
  25. return value;
  26. }
  27. int getChecks() {
  28. return checks;
  29. }
  30. };
  31.  
  32. int main() {
  33. Checker c(1);
  34. if (isOneOf(c.getValue(), 2, 3, 1, 4, 5))
  35. cout << "true" << endl;
  36. cout << "checks: " << c.getChecks() << endl;
  37. return 0;
  38. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
true
checks: 1