fork(23) download
  1. #include <iostream>
  2.  
  3. #define WEEK_DAYS \
  4. X(MON, "Monday", true) \
  5. X(TUE, "Tuesday", true) \
  6. X(WED, "Wednesday", true) \
  7. X(THU, "Thursday", true) \
  8. X(FRI, "Friday", true) \
  9. X(SAT, "Saturday", false) \
  10. X(SUN, "Sunday", false)
  11.  
  12. #define X(day, name, workday) day,
  13. enum WeekDay : size_t
  14. {
  15. WEEK_DAYS
  16. };
  17. #undef X
  18.  
  19. #define X(day, name, workday) name,
  20. char const *weekday_name[] =
  21. {
  22. WEEK_DAYS
  23. };
  24. #undef X
  25.  
  26. #define X(day, name, workday) workday,
  27. bool weekday_workday[]
  28. {
  29. WEEK_DAYS
  30. };
  31. #undef X
  32.  
  33. int main()
  34. {
  35. std::cout << "Enum value: " << WeekDay::THU << std::endl;
  36. std::cout << "Name string: " << weekday_name[WeekDay::THU] << std::endl;
  37. std::cout << std::boolalpha << "Work day: " << weekday_workday[WeekDay::THU] << std::endl;
  38.  
  39. WeekDay wd = SUN;
  40. std::cout << "Enum value: " << wd << std::endl;
  41. std::cout << "Name string: " << weekday_name[wd] << std::endl;
  42. std::cout << std::boolalpha << "Work day: " << weekday_workday[wd] << std::endl;
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0s 4524KB
stdin
Standard input is empty
stdout
Enum value: 3
Name string: Thursday
Work day: true
Enum value: 6
Name string: Sunday
Work day: false