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
11 #ifndef BOOST_MULTI_INDEX_TEST_PAIR_OF_INTS_HPP
12 #define BOOST_MULTI_INDEX_TEST_PAIR_OF_INTS_HPP
13
14 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
15 #include <boost/serialization/nvp.hpp>
16
17 struct pair_of_ints
18 {
pair_of_intspair_of_ints19 pair_of_ints(int first_=0,int second_=0):first(first_),second(second_){}
20
operator ==pair_of_ints21 bool operator==(const pair_of_ints& x)const
22 {
23 return first==x.first&&second==x.second;
24 }
25
operator !=pair_of_ints26 bool operator!=(const pair_of_ints& x)const{return !(*this==x);}
27
28 int first,second;
29 };
30
increment_first(pair_of_ints & p)31 inline void increment_first(pair_of_ints& p)
32 {
33 ++p.first;
34 }
35
increment_second(pair_of_ints & p)36 inline void increment_second(pair_of_ints& p)
37 {
38 ++p.second;
39 }
40
increment_int(int & x)41 inline void increment_int(int& x)
42 {
43 ++x;
44 }
45
decrement_first(pair_of_ints & p)46 inline int decrement_first(pair_of_ints& p)
47 {
48 return --p.first;
49 }
50
decrement_second(pair_of_ints & p)51 inline int decrement_second(pair_of_ints& p)
52 {
53 return --p.second;
54 }
55
decrement_int(int & x)56 inline int decrement_int(int& x)
57 {
58 return --x;
59 }
60
61 #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
62 namespace boost{
63 namespace serialization{
64 #endif
65
66 template<class Archive>
serialize(Archive & ar,pair_of_ints & p,const unsigned int)67 void serialize(Archive& ar,pair_of_ints& p,const unsigned int)
68 {
69 ar&boost::serialization::make_nvp("first",p.first);
70 ar&boost::serialization::make_nvp("second",p.second);
71 }
72
73 #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
74 } /* namespace serialization */
75 } /* namespace boost*/
76 #endif
77
78 #endif
79