rep.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // Adaptation to Boost of the libcxx
  10. // Copyright 2010 Vicente J. Botet Escriba
  11. // Distributed under the Boost Software License, Version 1.0.
  12. // See http://www.boost.org/LICENSE_1_0.txt
  13. #ifndef REP_H
  14. #define REP_H
  15. #include <boost/config.hpp>
  16. class Rep
  17. {
  18. public:
  19. int data_;
  20. BOOST_CONSTEXPR Rep() : data_() {}
  21. explicit BOOST_CONSTEXPR Rep(int i) : data_(i) {}
  22. BOOST_CONSTEXPR bool operator==(int i) const {return data_ == i;}
  23. BOOST_CONSTEXPR bool operator==(const Rep& r) const {return data_ == r.data_;}
  24. Rep& operator*=(Rep x) {data_ *= x.data_; return *this;}
  25. Rep& operator/=(Rep x) {data_ /= x.data_; return *this;}
  26. };
  27. #if 0
  28. namespace std {
  29. template <>
  30. struct numeric_limits<Rep>
  31. {
  32. static BOOST_CONSTEXPR Rep max BOOST_PREVENT_MACRO_SUBSTITUTION ()
  33. {
  34. return Rep((std::numeric_limits<int>::max)());
  35. }
  36. };
  37. } // namespace std
  38. namespace boost {
  39. namespace chrono {
  40. template <>
  41. struct duration_values<Rep>
  42. {
  43. static BOOST_CONSTEXPR Rep zero() {return Rep(0);}
  44. static BOOST_CONSTEXPR Rep max BOOST_PREVENT_MACRO_SUBSTITUTION ()
  45. {
  46. return Rep((std::numeric_limits<int>::max)());
  47. }
  48. static BOOST_CONSTEXPR Rep min BOOST_PREVENT_MACRO_SUBSTITUTION ()
  49. {
  50. return Rep(detail::numeric_limits<Rep>::lowest());
  51. }
  52. };
  53. } // namespace chrono
  54. } // namespace boost
  55. #endif
  56. #endif // REP_H