collection_size_type.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef BOOST_SERIALIZATION_COLLECTION_SIZE_TYPE_HPP
  2. #define BOOST_SERIALIZATION_COLLECTION_SIZE_TYPE_HPP
  3. // (C) Copyright 2005 Matthias Troyer
  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 <cstddef> // size_t
  8. #include <boost/serialization/strong_typedef.hpp>
  9. #include <boost/serialization/level.hpp>
  10. #include <boost/serialization/split_free.hpp>
  11. #include <boost/serialization/is_bitwise_serializable.hpp>
  12. namespace boost {
  13. namespace serialization {
  14. //BOOST_STRONG_TYPEDEF(std::size_t, collection_size_type)
  15. class collection_size_type {
  16. private:
  17. typedef std::size_t base_type;
  18. base_type t;
  19. public:
  20. collection_size_type(): t(0) {}
  21. explicit collection_size_type(const std::size_t & t_) :
  22. t(t_)
  23. {}
  24. collection_size_type(const collection_size_type & t_) :
  25. t(t_.t)
  26. {}
  27. collection_size_type & operator=(const collection_size_type & rhs){
  28. t = rhs.t;
  29. return *this;
  30. }
  31. collection_size_type & operator=(const unsigned int & rhs){
  32. t = rhs;
  33. return *this;
  34. }
  35. // used for text output
  36. operator base_type () const {
  37. return t;
  38. }
  39. // used for text input
  40. operator base_type & () {
  41. return t;
  42. }
  43. bool operator==(const collection_size_type & rhs) const {
  44. return t == rhs.t;
  45. }
  46. bool operator<(const collection_size_type & rhs) const {
  47. return t < rhs.t;
  48. }
  49. };
  50. } } // end namespace boost::serialization
  51. BOOST_CLASS_IMPLEMENTATION(collection_size_type, primitive_type)
  52. BOOST_IS_BITWISE_SERIALIZABLE(collection_size_type)
  53. #endif //BOOST_SERIALIZATION_COLLECTION_SIZE_TYPE_HPP