Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80405 - in trunk: boost/interprocess boost/interprocess/detail boost/interprocess/indexes boost/interprocess/sync/posix libs/interprocess/test
From: igaztanaga_at_[hidden]
Date: 2012-09-05 05:29:58


Author: igaztanaga
Date: 2012-09-05 05:29:56 EDT (Wed, 05 Sep 2012)
New Revision: 80405
URL: http://svn.boost.org/trac/boost/changeset/80405

Log:
Removed unused variables warnings + fixed comparison problems in test
Text files modified:
   trunk/boost/interprocess/detail/intermodule_singleton_common.hpp | 2
   trunk/boost/interprocess/indexes/iunordered_set_index.hpp | 2
   trunk/boost/interprocess/mapped_region.hpp | 4
   trunk/boost/interprocess/sync/posix/condition.hpp | 8 +-
   trunk/boost/interprocess/sync/posix/mutex.hpp | 1
   trunk/boost/interprocess/sync/posix/recursive_mutex.hpp | 2
   trunk/libs/interprocess/test/check_equal_containers.hpp | 24 +++++++++-
   trunk/libs/interprocess/test/deque_test.cpp | 2
   trunk/libs/interprocess/test/movable_int.hpp | 89 ++++++++++++++++++++++++++++++---------
   9 files changed, 100 insertions(+), 34 deletions(-)

Modified: trunk/boost/interprocess/detail/intermodule_singleton_common.hpp
==============================================================================
--- trunk/boost/interprocess/detail/intermodule_singleton_common.hpp (original)
+++ trunk/boost/interprocess/detail/intermodule_singleton_common.hpp 2012-09-05 05:29:56 EDT (Wed, 05 Sep 2012)
@@ -199,7 +199,7 @@
    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()

Modified: trunk/boost/interprocess/indexes/iunordered_set_index.hpp
==============================================================================
--- trunk/boost/interprocess/indexes/iunordered_set_index.hpp (original)
+++ trunk/boost/interprocess/indexes/iunordered_set_index.hpp 2012-09-05 05:29:56 EDT (Wed, 05 Sep 2012)
@@ -190,7 +190,7 @@
 
       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){

Modified: trunk/boost/interprocess/mapped_region.hpp
==============================================================================
--- trunk/boost/interprocess/mapped_region.hpp (original)
+++ trunk/boost/interprocess/mapped_region.hpp 2012-09-05 05:29:56 EDT (Wed, 05 Sep 2012)
@@ -689,8 +689,8 @@
 
 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;
    }

Modified: trunk/boost/interprocess/sync/posix/condition.hpp
==============================================================================
--- trunk/boost/interprocess/sync/posix/condition.hpp (original)
+++ trunk/boost/interprocess/sync/posix/condition.hpp 2012-09-05 05:29:56 EDT (Wed, 05 Sep 2012)
@@ -145,21 +145,21 @@
 {
     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 @@
    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

Modified: trunk/boost/interprocess/sync/posix/mutex.hpp
==============================================================================
--- trunk/boost/interprocess/sync/posix/mutex.hpp (original)
+++ trunk/boost/interprocess/sync/posix/mutex.hpp 2012-09-05 05:29:56 EDT (Wed, 05 Sep 2012)
@@ -140,6 +140,7 @@
 {
    int res = 0;
    res = pthread_mutex_unlock(&m_mut);
+ (void)res;
    BOOST_ASSERT(res == 0);
 }
 

Modified: trunk/boost/interprocess/sync/posix/recursive_mutex.hpp
==============================================================================
--- trunk/boost/interprocess/sync/posix/recursive_mutex.hpp (original)
+++ trunk/boost/interprocess/sync/posix/recursive_mutex.hpp 2012-09-05 05:29:56 EDT (Wed, 05 Sep 2012)
@@ -130,7 +130,7 @@
 {
    int res = 0;
    res = pthread_mutex_unlock(&m_mut);
- BOOST_ASSERT(res == 0);
+ BOOST_ASSERT(res == 0); (void)res;
 }
 
 } //namespace ipcdetail {

Modified: trunk/libs/interprocess/test/check_equal_containers.hpp
==============================================================================
--- trunk/libs/interprocess/test/check_equal_containers.hpp (original)
+++ trunk/libs/interprocess/test/check_equal_containers.hpp 2012-09-05 05:29:56 EDT (Wed, 05 Sep 2012)
@@ -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 @@
    }
    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;

Modified: trunk/libs/interprocess/test/deque_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/deque_test.cpp (original)
+++ trunk/libs/interprocess/test/deque_test.cpp 2012-09-05 05:29:56 EDT (Wed, 05 Sep 2012)
@@ -57,7 +57,7 @@
    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);

Modified: trunk/libs/interprocess/test/movable_int.hpp
==============================================================================
--- trunk/libs/interprocess/test/movable_int.hpp (original)
+++ trunk/libs/interprocess/test/movable_int.hpp 2012-09-05 05:29:56 EDT (Wed, 05 Sep 2012)
@@ -19,12 +19,21 @@
 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 @@
    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 @@
     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 @@
    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 @@
    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 @@
     return os;
 }
 
+template<>
+struct is_copyable<movable_and_copyable_int>
+{
+ static const bool value = true;
+};
+
 class copyable_int
 {
    public:
@@ -155,10 +189,7 @@
    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 @@
    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 @@
    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 {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk