fork download
  1. #include <string>
  2. //#include <cstdint> //Not needed;
  3. #include <iostream>
  4. #include <type_traits> //Not needed
  5. #include <unordered_map>
  6.  
  7.  
  8. /*
  9. Declare a scoped enum Experiance, it's like old c++ enum but
  10. compiller prevent cast to another types by default.
  11. Sample:
  12. Experiance exp = Experience::CPlusPlus11;
  13. int32_t iErrCast = exp //compile error: invalid type cast.
  14. int32_t iRightCast = static_cast<int32_t>( expr ) //Manual cast. it's ok
  15.  
  16. All this enum members is
  17. */
  18. enum class Experience : uint8_t {
  19. None = 0,
  20. Linux = 1 << 0,
  21. Multithreading = 1 << 1,
  22. Socket = 1 << 2,
  23. Highload = 1 << 3,
  24. CPlusPlus11 = 1 << 4,
  25. DataStructs = 1 << 5,
  26. Patterns = 1 << 6,
  27. Algorithms = 1 << 7,
  28. All = UINT8_MAX
  29. };
  30.  
  31. inline constexpr Experience operator|(Experience x, Experience y) {
  32. return static_cast<Experience>(static_cast<uint8_t>(x) | static_cast<uint8_t>(y));
  33. }
  34.  
  35. inline constexpr Experience operator&(Experience x, Experience y) {
  36. return static_cast<Experience>(static_cast<uint8_t>(x) & static_cast<uint8_t>(y));
  37. }
  38.  
  39. inline constexpr bool operator==(Experience x, Experience y) {
  40. return static_cast<uint8_t>(x) == static_cast<uint8_t>(y);
  41. }
  42.  
  43. template<Experience Mask>
  44. struct Applicant {
  45. static const bool value = ((Mask & Experience::All) == Experience::All);
  46. };
  47.  
  48. template<typename T>
  49. class Suitability {
  50. template<typename U>
  51. static int8_t f(typename std::enable_if<U::value, bool>::type*);
  52.  
  53. template<typename U>
  54. static int32_t f(...);
  55.  
  56. public:
  57. static const bool value = (sizeof(f<T>(0)) == sizeof(int8_t));
  58. };
  59.  
  60. int main(int argc, const char * argv[]) {
  61. std::unordered_map<uint8_t, std::string> result = { { 0, "Unsuitable" }, { 1, "Suitable" } };
  62. static constexpr Experience experience = Experience::None; // specify your skills here
  63. std::cout << result[Suitability<Applicant<experience>>::value] << std::endl;
  64. return 0;
  65. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
Unsuitable