1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #ifndef BOOST_INTERPROCESS_TEST_CHECK_EQUAL_CONTAINERS_HPP
12 #define BOOST_INTERPROCESS_TEST_CHECK_EQUAL_CONTAINERS_HPP
14 #include <boost/interprocess/detail/config_begin.hpp>
18 #include <boost/container/detail/pair.hpp>
21 namespace interprocess{
24 template< class T1, class T2>
25 bool CheckEqual( const T1 &t1, const T2 &t2
26 , typename boost::container::container_detail::enable_if_c
27 <!boost::container::container_detail::is_pair<T1>::value &&
28 !boost::container::container_detail::is_pair<T2>::value
32 template< class Pair1, class Pair2>
33 bool CheckEqual( const Pair1 &pair1, const Pair2 &pair2
34 , typename boost::container::container_detail::enable_if_c
35 <boost::container::container_detail::is_pair<Pair1>::value &&
36 boost::container::container_detail::is_pair<Pair2>::value
39 return CheckEqual(pair1.first, pair2.first) && CheckEqual(pair1.second, pair2.second);
43 //Function to check if both containers are equal
44 template<class MyShmCont
46 bool CheckEqualContainers(MyShmCont *shmcont, MyStdCont *stdcont)
48 if(shmcont->size() != stdcont->size())
51 typename MyShmCont::iterator itshm(shmcont->begin()), itshmend(shmcont->end());
52 typename MyStdCont::iterator itstd(stdcont->begin());
53 typename MyStdCont::size_type dist = (typename MyStdCont::size_type)std::distance(itshm, itshmend);
54 if(dist != shmcont->size()){
58 for(; itshm != itshmend; ++itshm, ++itstd, ++i){
59 if(!CheckEqual(*itstd, *itshm))
65 template<class MyShmCont
67 bool CheckEqualPairContainers(MyShmCont *shmcont, MyStdCont *stdcont)
69 if(shmcont->size() != stdcont->size())
72 typedef typename MyShmCont::key_type key_type;
73 typedef typename MyShmCont::mapped_type mapped_type;
75 typename MyShmCont::iterator itshm(shmcont->begin()), itshmend(shmcont->end());
76 typename MyStdCont::iterator itstd(stdcont->begin());
77 for(; itshm != itshmend; ++itshm, ++itstd){
78 if(itshm->first != key_type(itstd->first))
81 if(itshm->second != mapped_type(itstd->second))
87 } //namespace interprocess{
90 #include <boost/interprocess/detail/config_end.hpp>
92 #endif //#ifndef BOOST_INTERPROCESS_TEST_CHECK_EQUAL_CONTAINERS_HPP