pair_of_ints.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Used in Boost.MultiIndex tests.
  2. *
  3. * Copyright 2003-2010 Joaquin M Lopez Munoz.
  4. * Distributed under the Boost Software License, Version 1.0.
  5. * (See accompanying file LICENSE_1_0.txt or copy at
  6. * http://www.boost.org/LICENSE_1_0.txt)
  7. *
  8. * See http://www.boost.org/libs/multi_index for library home page.
  9. */
  10. #ifndef BOOST_MULTI_INDEX_TEST_PAIR_OF_INTS_HPP
  11. #define BOOST_MULTI_INDEX_TEST_PAIR_OF_INTS_HPP
  12. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  13. #include <boost/serialization/nvp.hpp>
  14. struct pair_of_ints
  15. {
  16. pair_of_ints(int first_=0,int second_=0):first(first_),second(second_){}
  17. bool operator==(const pair_of_ints& x)const
  18. {
  19. return first==x.first&&second==x.second;
  20. }
  21. bool operator!=(const pair_of_ints& x)const{return !(*this==x);}
  22. int first,second;
  23. };
  24. inline void increment_first(pair_of_ints& p)
  25. {
  26. ++p.first;
  27. }
  28. inline void increment_second(pair_of_ints& p)
  29. {
  30. ++p.second;
  31. }
  32. inline void increment_int(int& x)
  33. {
  34. ++x;
  35. }
  36. inline int decrement_first(pair_of_ints& p)
  37. {
  38. return --p.first;
  39. }
  40. inline int decrement_second(pair_of_ints& p)
  41. {
  42. return --p.second;
  43. }
  44. inline int decrement_int(int& x)
  45. {
  46. return --x;
  47. }
  48. #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
  49. namespace boost{
  50. namespace serialization{
  51. #endif
  52. template<class Archive>
  53. void serialize(Archive& ar,pair_of_ints& p,const unsigned int)
  54. {
  55. ar&boost::serialization::make_nvp("first",p.first);
  56. ar&boost::serialization::make_nvp("second",p.second);
  57. }
  58. #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
  59. } /* namespace serialization */
  60. } /* namespace boost*/
  61. #endif
  62. #endif