| 1 | /* Used in Boost.MultiIndex tests. |
| 2 | * |
| 3 | * Copyright 2003-2023 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/core/serialization.hpp> |
| 16 | |
| 17 | struct pair_of_ints |
| 18 | { |
| 19 | pair_of_ints(int first_=0,int second_=0):first(first_),second(second_){} |
| 20 | |
| 21 | bool operator==(const pair_of_ints& x)const |
| 22 | { |
| 23 | return first==x.first&&second==x.second; |
| 24 | } |
| 25 | |
| 26 | bool operator!=(const pair_of_ints& x)const{return !(*this==x);} |
| 27 | |
| 28 | int first,second; |
| 29 | }; |
| 30 | |
| 31 | inline void increment_first(pair_of_ints& p) |
| 32 | { |
| 33 | ++p.first; |
| 34 | } |
| 35 | |
| 36 | inline void increment_second(pair_of_ints& p) |
| 37 | { |
| 38 | ++p.second; |
| 39 | } |
| 40 | |
| 41 | inline void increment_int(int& x) |
| 42 | { |
| 43 | ++x; |
| 44 | } |
| 45 | |
| 46 | inline int decrement_first(pair_of_ints& p) |
| 47 | { |
| 48 | return --p.first; |
| 49 | } |
| 50 | |
| 51 | inline int decrement_second(pair_of_ints& p) |
| 52 | { |
| 53 | return --p.second; |
| 54 | } |
| 55 | |
| 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> |
| 67 | void serialize(Archive& ar,pair_of_ints& p,const unsigned int) |
| 68 | { |
| 69 | ar&boost::core::make_nvp(n: "first" ,v&: p.first); |
| 70 | ar&boost::core::make_nvp(n: "second" ,v&: p.second); |
| 71 | } |
| 72 | |
| 73 | #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) |
| 74 | } /* namespace serialization */ |
| 75 | } /* namespace boost*/ |
| 76 | #endif |
| 77 | |
| 78 | #endif |
| 79 | |