fork download
  1. #include <functional>
  2. #include <vector>
  3. #include <iostream>
  4.  
  5. #define DEVICE_A 0
  6. #define DEVICE_B 1
  7. //..
  8. #define DEVICE_N 50
  9.  
  10. #define COMPANY_A 0
  11. #define COMPANY_B 1
  12. #define COMPANY_C 2
  13. #define COMPANY_D 2
  14. //..
  15. #define COMPANY_N 50
  16.  
  17. int main ()
  18. {
  19. int giCompany_1 = COMPANY_B;
  20. int giCompany_2 = COMPANY_D;
  21. int giDevice = DEVICE_A;
  22. int randomValue_1 = 5;
  23. int randomValue_2 = 7;
  24. std::vector<std::pair<std::function<bool()>, std::function<void()>>> operations =
  25. {
  26. {
  27. [=] {return giCompany_1 == COMPANY_A || giCompany_1 == COMPANY_B || giCompany_1 != COMPANY_C && giDevice == DEVICE_A;},
  28. [&] {std::cout << "First case " << randomValue_1 << '\n';}
  29. },
  30. {
  31. [=] {return giCompany_2 == COMPANY_D;},
  32. [&] {std::cout << "Second case " << randomValue_2 << '\n';}
  33. },
  34. };
  35.  
  36. for (auto const& pair: operations)
  37. {
  38. if (pair.first ())
  39. {
  40. pair.second ();
  41. }
  42. }
  43. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
First case 5
Second case 7