cv_status.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // cv_status.hpp
  2. //
  3. // Copyright (C) 2011 Vicente J. Botet Escriba
  4. // Copyright (C) 2021 Ion Gaztanaga
  5. //
  6. // Distributed under the Boost Software License, Version 1.0. (See
  7. // accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. #ifndef BOOST_INTERPROCESS_CV_STATUS_HPP
  10. #define BOOST_INTERPROCESS_CV_STATUS_HPP
  11. #include <boost/config.hpp>
  12. namespace boost {
  13. namespace interprocess {
  14. #if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
  15. enum class cv_status
  16. {
  17. no_timeout,
  18. timeout
  19. };
  20. #else //BOOST_NO_CXX11_SCOPED_ENUMS
  21. // enum class cv_status emulation
  22. struct cv_status
  23. {
  24. typedef void is_boost_scoped_enum_tag;
  25. typedef int underlying_type;
  26. cv_status() {}
  27. explicit cv_status(underlying_type v)
  28. : v_(v)
  29. {}
  30. underlying_type get_underlying_value_() const { return v_; }
  31. private:
  32. underlying_type v_;
  33. typedef cv_status self_type;
  34. public:
  35. enum enum_type
  36. {
  37. no_timeout,
  38. timeout
  39. };
  40. cv_status(enum_type v)
  41. : v_(v)
  42. {}
  43. enum_type get_native_value_() const
  44. { return enum_type(v_); }
  45. friend bool operator ==(self_type lhs, self_type rhs)
  46. { return enum_type(lhs.v_)==enum_type(rhs.v_); }
  47. friend bool operator ==(self_type lhs, enum_type rhs)
  48. { return enum_type(lhs.v_)==rhs; }
  49. friend bool operator ==(enum_type lhs, self_type rhs)
  50. { return lhs==enum_type(rhs.v_); }
  51. friend bool operator !=(self_type lhs, self_type rhs)
  52. { return enum_type(lhs.v_)!=enum_type(rhs.v_); }
  53. friend bool operator !=(self_type lhs, enum_type rhs)
  54. { return enum_type(lhs.v_)!=rhs; }
  55. friend bool operator !=(enum_type lhs, self_type rhs)
  56. { return lhs!=enum_type(rhs.v_); }
  57. friend bool operator <(self_type lhs, self_type rhs)
  58. { return enum_type(lhs.v_)<enum_type(rhs.v_); }
  59. friend bool operator <(self_type lhs, enum_type rhs)
  60. { return enum_type(lhs.v_)<rhs; }
  61. friend bool operator <(enum_type lhs, self_type rhs)
  62. { return lhs<enum_type(rhs.v_); }
  63. friend bool operator <=(self_type lhs, self_type rhs)
  64. { return enum_type(lhs.v_)<=enum_type(rhs.v_); }
  65. friend bool operator <=(self_type lhs, enum_type rhs)
  66. { return enum_type(lhs.v_)<=rhs; }
  67. friend bool operator <=(enum_type lhs, self_type rhs)
  68. { return lhs<=enum_type(rhs.v_); }
  69. friend bool operator >(self_type lhs, self_type rhs)
  70. { return enum_type(lhs.v_)>enum_type(rhs.v_); }
  71. friend bool operator >(self_type lhs, enum_type rhs)
  72. { return enum_type(lhs.v_)>rhs; }
  73. friend bool operator >(enum_type lhs, self_type rhs)
  74. { return lhs>enum_type(rhs.v_); }
  75. friend bool operator >=(self_type lhs, self_type rhs)
  76. { return enum_type(lhs.v_)>=enum_type(rhs.v_); }
  77. friend bool operator >=(self_type lhs, enum_type rhs)
  78. { return enum_type(lhs.v_)>=rhs; }
  79. friend bool operator >=(enum_type lhs, self_type rhs)
  80. { return lhs>=enum_type(rhs.v_); }
  81. };
  82. #endif
  83. } //namespace interprocess
  84. } //namespace boost
  85. #endif // header