Removed unused variables warnings + fixed comparison problems in test

[SVN r80405]
This commit is contained in:
Ion Gaztañaga
2012-09-05 09:29:56 +00:00
parent fcaaaa52f8
commit 00066b5506
9 changed files with 100 additions and 34 deletions

View File

@@ -199,7 +199,7 @@ class intermodule_singleton_common
private:
static ThreadSafeGlobalMap &get_map()
{
return *static_cast<ThreadSafeGlobalMap *>(static_cast<void *>(&mem_holder.map_mem));
return *static_cast<ThreadSafeGlobalMap *>(static_cast<void *>(&mem_holder.map_mem[0]));
}
static void initialize_global_map_handle()

View File

@@ -190,7 +190,7 @@ class iunordered_set_index
bucket_ptr shunk_p = alloc.allocation_command
(boost::interprocess::shrink_in_place | boost::interprocess::nothrow_allocation, received_size, received_size, received_size, buckets).first;
BOOST_ASSERT(buckets == shunk_p);
BOOST_ASSERT(buckets == shunk_p); (void)shunk_p;
bucket_ptr buckets_init = buckets + received_size;
for(size_type i = 0; i < (old_size - received_size); ++i){

View File

@@ -689,8 +689,8 @@ inline mapped_region::mapped_region
inline bool mapped_region::shrink_by(std::size_t bytes, bool from_back)
{
void *shrink_page_start;
std::size_t shrink_page_bytes;
void *shrink_page_start = 0;
std::size_t shrink_page_bytes = 0;
if(m_is_xsi || !this->priv_shrink_param_check(bytes, from_back, shrink_page_start, shrink_page_bytes)){
return false;
}

View File

@@ -145,21 +145,21 @@ inline posix_condition::~posix_condition()
{
int res = 0;
res = pthread_cond_destroy(&m_condition);
BOOST_ASSERT(res == 0);
BOOST_ASSERT(res == 0); (void)res;
}
inline void posix_condition::notify_one()
{
int res = 0;
res = pthread_cond_signal(&m_condition);
BOOST_ASSERT(res == 0);
BOOST_ASSERT(res == 0); (void)res;
}
inline void posix_condition::notify_all()
{
int res = 0;
res = pthread_cond_broadcast(&m_condition);
BOOST_ASSERT(res == 0);
BOOST_ASSERT(res == 0); (void)res;
}
inline void posix_condition::do_wait(posix_mutex &mut)
@@ -167,7 +167,7 @@ inline void posix_condition::do_wait(posix_mutex &mut)
pthread_mutex_t* pmutex = &mut.m_mut;
int res = 0;
res = pthread_cond_wait(&m_condition, pmutex);
BOOST_ASSERT(res == 0);
BOOST_ASSERT(res == 0); (void)res;
}
inline bool posix_condition::do_timed_wait

View File

@@ -140,6 +140,7 @@ inline void posix_mutex::unlock()
{
int res = 0;
res = pthread_mutex_unlock(&m_mut);
(void)res;
BOOST_ASSERT(res == 0);
}

View File

@@ -130,7 +130,7 @@ inline void posix_recursive_mutex::unlock()
{
int res = 0;
res = pthread_mutex_unlock(&m_mut);
BOOST_ASSERT(res == 0);
BOOST_ASSERT(res == 0); (void)res;
}
} //namespace ipcdetail {

View File

@@ -15,11 +15,31 @@
#include <functional>
#include <iostream>
#include <algorithm>
#include <boost/container/detail/pair.hpp>
namespace boost{
namespace interprocess{
namespace test{
template< class T1, class T2>
bool CheckEqual( const T1 &t1, const T2 &t2
, typename boost::container::container_detail::enable_if_c
<!boost::container::container_detail::is_pair<T1>::value &&
!boost::container::container_detail::is_pair<T2>::value
>::type* = 0)
{ return t1 == t2; }
template< class Pair1, class Pair2>
bool CheckEqual( const Pair1 &pair1, const Pair2 &pair2
, typename boost::container::container_detail::enable_if_c
<boost::container::container_detail::is_pair<Pair1>::value &&
boost::container::container_detail::is_pair<Pair2>::value
>::type* = 0)
{
return CheckEqual(pair1.first, pair2.first) && CheckEqual(pair1.second, pair2.second);
}
//Function to check if both containers are equal
template<class MyShmCont
,class MyStdCont>
@@ -38,9 +58,7 @@ bool CheckEqualContainers(MyShmCont *shmcont, MyStdCont *stdcont)
}
std::size_t i = 0;
for(; itshm != itshmend; ++itshm, ++itstd, ++i){
value_type val(*itstd);
const value_type &v = *itshm;
if(v != val)
if(!CheckEqual(*itstd, *itshm))
return false;
}
return true;

View File

@@ -57,7 +57,7 @@ bool copyable_only(V1 *shmdeque, V2 *stddeque, ipcdetail::true_type)
typedef typename V1::value_type IntType;
std::size_t size = shmdeque->size();
stddeque->insert(stddeque->end(), 50, 1);
shmdeque->insert(shmdeque->end(), 50, 1);
shmdeque->insert(shmdeque->end(), 50, IntType(1));
if(!test::CheckEqualContainers(shmdeque, stddeque)) return false;
{
IntType move_me(1);

View File

@@ -19,12 +19,21 @@ namespace boost {
namespace interprocess {
namespace test {
template<class T>
struct is_copyable;
template<>
struct is_copyable<int>
{
static const bool value = true;
};
class movable_int
{
BOOST_MOVABLE_BUT_NOT_COPYABLE(movable_int)
public:
movable_int()
: m_int(0)
{}
@@ -64,6 +73,12 @@ class movable_int
int get_int() const
{ return m_int; }
friend bool operator==(const movable_int &l, int r)
{ return l.get_int() == r; }
friend bool operator==(int l, const movable_int &r)
{ return l == r.get_int(); }
private:
int m_int;
};
@@ -77,11 +92,18 @@ std::basic_ostream<E, T> & operator<<
return os;
}
template<>
struct is_copyable<movable_int>
{
static const bool value = false;
};
class movable_and_copyable_int
{
BOOST_COPYABLE_AND_MOVABLE(movable_and_copyable_int)
public:
public:
movable_and_copyable_int()
: m_int(0)
{}
@@ -93,14 +115,14 @@ class movable_and_copyable_int
movable_and_copyable_int(const movable_and_copyable_int& mmi)
: m_int(mmi.m_int)
{}
movable_and_copyable_int &operator= (BOOST_COPY_ASSIGN_REF(movable_and_copyable_int) mi)
{ this->m_int = mi.m_int; return *this; }
movable_and_copyable_int(BOOST_RV_REF(movable_and_copyable_int) mmi)
: m_int(mmi.m_int)
{ mmi.m_int = 0; }
movable_and_copyable_int &operator= (BOOST_COPY_ASSIGN_REF(movable_and_copyable_int) mi)
{ this->m_int = mi.m_int; return *this; }
movable_and_copyable_int & operator= (BOOST_RV_REF(movable_and_copyable_int) mmi)
{ this->m_int = mmi.m_int; mmi.m_int = 0; return *this; }
@@ -128,6 +150,12 @@ class movable_and_copyable_int
int get_int() const
{ return m_int; }
friend bool operator==(const movable_and_copyable_int &l, int r)
{ return l.get_int() == r; }
friend bool operator==(int l, const movable_and_copyable_int &r)
{ return l == r.get_int(); }
private:
int m_int;
};
@@ -141,6 +169,12 @@ std::basic_ostream<E, T> & operator<<
return os;
}
template<>
struct is_copyable<movable_and_copyable_int>
{
static const bool value = true;
};
class copyable_int
{
public:
@@ -155,10 +189,7 @@ class copyable_int
copyable_int(const copyable_int& mmi)
: m_int(mmi.m_int)
{}
copyable_int & operator= (const copyable_int &mi)
{ this->m_int = mi.m_int; return *this; }
copyable_int & operator= (int i)
{ this->m_int = i; return *this; }
@@ -183,10 +214,31 @@ class copyable_int
int get_int() const
{ return m_int; }
friend bool operator==(const copyable_int &l, int r)
{ return l.get_int() == r; }
friend bool operator==(int l, const copyable_int &r)
{ return l == r.get_int(); }
private:
int m_int;
};
template<class E, class T>
std::basic_ostream<E, T> & operator<<
(std::basic_ostream<E, T> & os, copyable_int const & p)
{
os << p.get_int();
return os;
}
template<>
struct is_copyable<copyable_int>
{
static const bool value = true;
};
class non_copymovable_int
{
non_copymovable_int(const non_copymovable_int& mmi);
@@ -222,21 +274,16 @@ class non_copymovable_int
int get_int() const
{ return m_int; }
friend bool operator==(const non_copymovable_int &l, int r)
{ return l.get_int() == r; }
friend bool operator==(int l, const non_copymovable_int &r)
{ return l == r.get_int(); }
private:
int m_int;
};
template<class E, class T>
std::basic_ostream<E, T> & operator<<
(std::basic_ostream<E, T> & os, copyable_int const & p)
{
os << p.get_int();
return os;
}
} //namespace test {
} //namespace interprocess {
} //namespace boost {