item_version_type.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef BOOST_SERIALIZATION_ITEM_VERSION_TYPE_HPP
  2. #define BOOST_SERIALIZATION_ITEM_VERSION_TYPE_HPP
  3. // (C) Copyright 2010 Robert Ramey
  4. // Use, modification and distribution is subject to the Boost Software
  5. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <boost/cstdint.hpp> // uint_least8_t
  8. #include <boost/integer_traits.hpp>
  9. #include <boost/serialization/level.hpp>
  10. #include <boost/serialization/is_bitwise_serializable.hpp>
  11. // fixes broken example build on x86_64-linux-gnu-gcc-4.6.0
  12. #include <boost/assert.hpp>
  13. namespace boost {
  14. namespace serialization {
  15. #if defined(_MSC_VER)
  16. #pragma warning( push )
  17. #pragma warning( disable : 4244 4267 )
  18. #endif
  19. class item_version_type {
  20. private:
  21. typedef unsigned int base_type;
  22. base_type t;
  23. public:
  24. // should be private - but MPI fails if it's not!!!
  25. item_version_type(): t(0) {};
  26. explicit item_version_type(const unsigned int t_) : t(t_){
  27. BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
  28. }
  29. item_version_type(const item_version_type & t_) :
  30. t(t_.t)
  31. {}
  32. item_version_type & operator=(item_version_type rhs){
  33. t = rhs.t;
  34. return *this;
  35. }
  36. // used for text output
  37. operator base_type () const {
  38. return t;
  39. }
  40. // used for text input
  41. operator base_type & () {
  42. return t;
  43. }
  44. bool operator==(const item_version_type & rhs) const {
  45. return t == rhs.t;
  46. }
  47. bool operator<(const item_version_type & rhs) const {
  48. return t < rhs.t;
  49. }
  50. };
  51. #if defined(_MSC_VER)
  52. #pragma warning( pop )
  53. #endif
  54. } } // end namespace boost::serialization
  55. BOOST_IS_BITWISE_SERIALIZABLE(item_version_type)
  56. BOOST_CLASS_IMPLEMENTATION(item_version_type, primitive_type)
  57. #endif //BOOST_SERIALIZATION_ITEM_VERSION_TYPE_HPP