|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r80365 - in sandbox/libpoet/trunk: poet test
From: fmhess_at_[hidden]
Date: 2012-09-02 15:53:15
Author: fmhess
Date: 2012-09-02 15:53:14 EDT (Sun, 02 Sep 2012)
New Revision: 80365
URL: http://svn.boost.org/trac/boost/changeset/80365
Log:
Fixed some compile errors when compiling in C++11 mode.
Text files modified:
sandbox/libpoet/trunk/poet/future.hpp | 9 +
sandbox/libpoet/trunk/poet/future_select.hpp | 2
sandbox/libpoet/trunk/poet/monitor_locks.hpp | 238 +++++++++++++++++++++++++++++++--------
sandbox/libpoet/trunk/test/Makefile | 8
4 files changed, 200 insertions(+), 57 deletions(-)
Modified: sandbox/libpoet/trunk/poet/future.hpp
==============================================================================
--- sandbox/libpoet/trunk/poet/future.hpp (original)
+++ sandbox/libpoet/trunk/poet/future.hpp 2012-09-02 15:53:14 EDT (Sun, 02 Sep 2012)
@@ -113,7 +113,10 @@
if(_posting_closed) return connection;
- slot_type slot(&waiter_event_queue::post<event_queue::event_type>, this, _1);
+ //The following static_cast is just there to work around what I think is a g++ 4.4.5 bug when
+ //compiling in c++0x mode (it gives a compile error without the cast)
+ slot_type slot(static_cast<void (waiter_event_queue::*)(const event_queue::event_type &)>
+ (&waiter_event_queue::post<event_queue::event_type>), this, _1);
BOOST_ASSERT(_weak_this.expired() == false);
slot.track(_weak_this);
connection = other._event_posted.connect(slot);
@@ -505,7 +508,7 @@
{}
~promise_body()
{
- renege(copy_exception(uncertain_future()));
+ renege(poet::copy_exception(uncertain_future()));
}
void fulfill(const T &value)
@@ -960,7 +963,7 @@
{
boost::shared_ptr<typename nonvoid_future_body_base<T>::type> new_object(
future_body<typename nonvoid<T>::type>::create());
- new_object->cancel(copy_exception(uncertain_future()));
+ new_object->cancel(poet::copy_exception(uncertain_future()));
return new_object;
}
};
Modified: sandbox/libpoet/trunk/poet/future_select.hpp
==============================================================================
--- sandbox/libpoet/trunk/poet/future_select.hpp (original)
+++ sandbox/libpoet/trunk/poet/future_select.hpp 2012-09-02 15:53:14 EDT (Sun, 02 Sep 2012)
@@ -137,7 +137,7 @@
for(i = 0; i < extra_selected; ++i)
{
dependent = _selected_promises.back().lock();
- if(dependent) dependent->cancel(copy_exception(uncertain_future()));
+ if(dependent) dependent->cancel(poet::copy_exception(uncertain_future()));
_selected_promises.pop_back();
}
Modified: sandbox/libpoet/trunk/poet/monitor_locks.hpp
==============================================================================
--- sandbox/libpoet/trunk/poet/monitor_locks.hpp (original)
+++ sandbox/libpoet/trunk/poet/monitor_locks.hpp 2012-09-02 15:53:14 EDT (Sun, 02 Sep 2012)
@@ -76,9 +76,16 @@
{
set_wait_function();
}
+ //move constructors
template<typename OtherLock>
+ #if BOOST_NO_RVALUE_REFERENCES
lock_wrapper(boost::detail::thread_move_t<OtherLock> other):
_mon(other->_mon), _mon_raw_ptr(other->_mon_raw_ptr), _lock(other->_lock.move())
+ #else
+ lock_wrapper(OtherLock &&other):
+ _mon(std::move(other._mon)), _mon_raw_ptr(std::move(other._mon_raw_ptr)),
+ _lock(std::move(other._lock))
+ #endif
{
set_wait_function();
}
@@ -222,6 +229,8 @@
monitor_unique_lock(Monitor &mon, const U &arg):
base_class(mon, arg)
{}
+
+ #ifdef BOOST_NO_RVALUE_REFERENCES
// move constructors
monitor_unique_lock(boost::detail::thread_move_t<monitor_unique_lock> other):
base_class(other)
@@ -235,6 +244,7 @@
{
return boost::detail::thread_move_t<monitor_unique_lock>(*this);
}
+
template<typename Lock>
monitor_unique_lock& operator=(boost::detail::thread_move_t<Lock> other)
{
@@ -246,6 +256,30 @@
{
return move();
}
+
+ #else
+ monitor_unique_lock(monitor_unique_lock &&other):
+ base_class(std::move(other))
+ {}
+ monitor_unique_lock(monitor_upgrade_lock<Monitor> &&other):
+ base_class(std::move(other))
+ {}
+
+ // move emulation
+ monitor_unique_lock&& move()
+ {
+ return std::move(*this);
+ }
+
+ template<typename Lock>
+ monitor_unique_lock& operator=(Lock &&other)
+ {
+ monitor_unique_lock temp(std::move(other));
+ this->swap(temp);
+ return *this;
+ }
+ #endif
+
};
template<typename Monitor>
@@ -254,12 +288,21 @@
lockA.swap(lockB);
}
+#ifdef BOOST_NO_RVALUE_REFERENCES
template<typename Monitor>
boost::detail::thread_move_t<monitor_unique_lock<Monitor> >
move(monitor_unique_lock<Monitor> &lock)
{
return lock.move();
}
+#else
+ template<typename Monitor>
+ monitor_unique_lock<Monitor> &&
+ move(monitor_unique_lock<Monitor> &lock)
+ {
+ return std::move(lock);
+ }
+#endif
template<typename Monitor>
class monitor_shared_lock: public detail::lock_wrapper<Monitor,
@@ -279,6 +322,7 @@
monitor_shared_lock(Monitor &mon, const U &arg):
base_class(mon, arg)
{}
+ #ifdef BOOST_NO_RVALUE_REFERENCES
// move constructors
monitor_shared_lock(boost::detail::thread_move_t<monitor_shared_lock> other):
base_class(other)
@@ -290,6 +334,48 @@
base_class(other)
{}
+ // move emulation
+ boost::detail::thread_move_t<monitor_shared_lock> move()
+ {
+ return boost::detail::thread_move_t<monitor_shared_lock>(*this);
+ }
+ template<typename Lock>
+ monitor_shared_lock& operator=(boost::detail::thread_move_t<Lock> other)
+ {
+ monitor_shared_lock temp(other);
+ this->swap(temp);
+ return *this;
+ }
+ operator boost::detail::thread_move_t<monitor_shared_lock>()
+ {
+ return move();
+ }
+ #else
+ // move constructors
+ monitor_shared_lock(monitor_shared_lock<Monitor> &&other):
+ base_class(std::move(other))
+ {}
+ monitor_shared_lock(monitor_upgrade_lock<Monitor> &&other):
+ base_class(std::move(other))
+ {}
+ monitor_shared_lock(monitor_unique_lock<Monitor> &&other):
+ base_class(std::move(other))
+ {}
+
+ // move emulation
+ monitor_shared_lock&& move()
+ {
+ return std::move(*this);
+ }
+ template<typename Lock>
+ monitor_shared_lock& operator=(Lock &&other)
+ {
+ monitor_shared_lock temp(std::move(other));
+ this->swap(temp);
+ return *this;
+ }
+ #endif
+
// monitor extensions to lock interface, only allow pointer to const access for shared_lock
const typename base_class::element_type* operator->() const
{
@@ -307,23 +393,6 @@
}
return *this->_mon.direct().get();
}
-
- // move emulation
- boost::detail::thread_move_t<monitor_shared_lock> move()
- {
- return boost::detail::thread_move_t<monitor_shared_lock>(*this);
- }
- template<typename Lock>
- monitor_shared_lock& operator=(boost::detail::thread_move_t<Lock> other)
- {
- monitor_shared_lock temp(other);
- this->swap(temp);
- return *this;
- }
- operator boost::detail::thread_move_t<monitor_shared_lock>()
- {
- return move();
- }
};
template<typename Monitor>
@@ -332,12 +401,21 @@
lockA.swap(lockB);
}
+#ifdef BOOST_NO_RVALUE_REFERENCES
template<typename Monitor>
boost::detail::thread_move_t<monitor_shared_lock<Monitor> >
move(monitor_shared_lock<Monitor> &lock)
{
return lock.move();
}
+#else
+ template<typename Monitor>
+ monitor_shared_lock<Monitor> &&
+ move(monitor_shared_lock<Monitor> &lock)
+ {
+ return std::move(lock);
+ }
+#endif
template<typename Monitor>
class monitor_upgrade_lock: public detail::lock_wrapper<Monitor,
@@ -357,6 +435,7 @@
monitor_upgrade_lock(Monitor &mon, const U &arg):
base_class(mon, arg)
{}
+ #ifdef BOOST_NO_RVALUE_REFERENCES
// move constructors
monitor_upgrade_lock(boost::detail::thread_move_t<monitor_upgrade_lock> other):
base_class(other)
@@ -365,6 +444,45 @@
base_class(other)
{}
+ // move emulation
+ boost::detail::thread_move_t<monitor_upgrade_lock> move()
+ {
+ return boost::detail::thread_move_t<monitor_upgrade_lock>(*this);
+ }
+ template<typename Lock>
+ monitor_upgrade_lock& operator=(boost::detail::thread_move_t<Lock> other)
+ {
+ monitor_upgrade_lock temp(other);
+ this->swap(temp);
+ return *this;
+ }
+ operator boost::detail::thread_move_t<monitor_upgrade_lock>()
+ {
+ return move();
+ }
+ #else
+ // move constructors
+ monitor_upgrade_lock(monitor_upgrade_lock<Monitor> && other):
+ base_class(std::move(other))
+ {}
+ monitor_upgrade_lock(monitor_unique_lock<Monitor> && other):
+ base_class(std::move(other))
+ {}
+
+ // move emulation
+ monitor_upgrade_lock && move()
+ {
+ return std::move(*this);
+ }
+ template<typename Lock>
+ monitor_upgrade_lock& operator=(Lock && other)
+ {
+ monitor_upgrade_lock temp(std::move(other));
+ this->swap(temp);
+ return *this;
+ }
+ #endif
+
// monitor extensions to lock interface, only allow pointer to const access for upgrade_lock
const typename base_class::element_type* operator->() const
{
@@ -382,23 +500,6 @@
}
return *this->_mon.direct().get();
}
-
- // move emulation
- boost::detail::thread_move_t<monitor_upgrade_lock> move()
- {
- return boost::detail::thread_move_t<monitor_upgrade_lock>(*this);
- }
- template<typename Lock>
- monitor_upgrade_lock& operator=(boost::detail::thread_move_t<Lock> other)
- {
- monitor_upgrade_lock temp(other);
- this->swap(temp);
- return *this;
- }
- operator boost::detail::thread_move_t<monitor_upgrade_lock>()
- {
- return move();
- }
};
template<typename Monitor>
@@ -407,12 +508,21 @@
lockA.swap(lockB);
}
+#ifdef BOOST_NO_RVALUE_REFERENCES
template<typename Monitor>
boost::detail::thread_move_t<monitor_upgrade_lock<Monitor> >
move(monitor_upgrade_lock<Monitor> &lock)
{
return lock.move();
}
+#else
+ template<typename Monitor>
+ monitor_upgrade_lock<Monitor> &&
+ move(monitor_upgrade_lock<Monitor> &lock)
+ {
+ return std::move(lock);
+ }
+#endif
template<typename Monitor>
class monitor_upgrade_to_unique_lock
@@ -427,10 +537,43 @@
_mon(upgrade_lock._mon),
_lock(upgrade_lock._lock)
{}
+ #ifdef BOOST_NO_RVALUE_REFERENCES
// move constructor
monitor_upgrade_to_unique_lock(boost::detail::thread_move_t<monitor_upgrade_to_unique_lock> other):
_mon(other->_mon), _lock(boost::detail::thread_move_t<wrapped_lock_type>(other->_lock))
{}
+ // move emulation
+ boost::detail::thread_move_t<monitor_upgrade_to_unique_lock> move()
+ {
+ return boost::detail::thread_move_t<monitor_upgrade_to_unique_lock>(*this);
+ }
+ monitor_upgrade_to_unique_lock& operator=(boost::detail::thread_move_t<monitor_upgrade_to_unique_lock> other)
+ {
+ monitor_upgrade_to_unique_lock temp(other);
+ swap(temp);
+ return *this;
+ }
+ operator boost::detail::thread_move_t<monitor_upgrade_to_unique_lock>()
+ {
+ return move();
+ }
+ #else
+ // move constructor
+ monitor_upgrade_to_unique_lock(monitor_upgrade_to_unique_lock<Monitor> &&other):
+ _mon(std::move(other._mon)), _lock(std::move(other._lock))
+ {}
+ // move emulation
+ monitor_upgrade_to_unique_lock&& move()
+ {
+ return std::move(*this);
+ }
+ monitor_upgrade_to_unique_lock& operator=(monitor_upgrade_to_unique_lock<Monitor> &&other)
+ {
+ monitor_upgrade_to_unique_lock temp(std::move(other));
+ swap(temp);
+ return *this;
+ }
+ #endif
void swap(monitor_upgrade_to_unique_lock &other)
{
@@ -471,21 +614,6 @@
return *_mon.direct().get();
}
- // move emulation
- boost::detail::thread_move_t<monitor_upgrade_to_unique_lock> move()
- {
- return boost::detail::thread_move_t<monitor_upgrade_to_unique_lock>(*this);
- }
- monitor_upgrade_to_unique_lock& operator=(boost::detail::thread_move_t<monitor_upgrade_to_unique_lock> other)
- {
- monitor_upgrade_to_unique_lock temp(other);
- swap(temp);
- return *this;
- }
- operator boost::detail::thread_move_t<monitor_upgrade_to_unique_lock>()
- {
- return move();
- }
private:
monitor_ptr_type _mon;
wrapped_lock_type _lock;
@@ -497,16 +625,27 @@
lockA.swap(lockB);
}
+#ifdef BOOST_NO_RVALUE_REFERENCES
template<typename Monitor>
boost::detail::thread_move_t<monitor_upgrade_to_unique_lock<Monitor> >
move(monitor_upgrade_to_unique_lock<Monitor> &lock)
{
return lock.move();
}
+#else
+ template<typename Monitor>
+ monitor_upgrade_to_unique_lock<Monitor> &&
+ move(monitor_upgrade_to_unique_lock<Monitor> &lock)
+ {
+ return std::move(lock);
+ }
+#endif
+
};
namespace boost
{
+#ifdef BOOST_NO_RVALUE_REFERENCES
template<typename T>
detail::thread_move_t<poet::monitor_unique_lock<T> >
move(const detail::thread_move_t<poet::monitor_unique_lock<T> > &x)
@@ -531,6 +670,7 @@
{
return x;
}
+#endif
}
#endif // _POET_MONITOR_LOCKS_HPP
Modified: sandbox/libpoet/trunk/test/Makefile
==============================================================================
--- sandbox/libpoet/trunk/test/Makefile (original)
+++ sandbox/libpoet/trunk/test/Makefile 2012-09-02 15:53:14 EDT (Sun, 02 Sep 2012)
@@ -1,5 +1,5 @@
-BOOST_INC_DIR=/home/fhess/svn/boost_switch
-BOOST_LIB_DIR=/home/fhess/svn/boost_switch/stage/lib
+BOOST_INC_DIR=/home/fhess/svn/boost_trunk
+BOOST_LIB_DIR=/home/fhess/svn/boost_trunk/stage/lib
CXX=g++
#set CC since it is used for linking .o files by built-in rule
CC=$(CXX)
@@ -15,8 +15,8 @@
not_default_constructible_test promise_count_test timed_join_test undead_active_function_test
CPPFLAGS= -pthread -I.. -I$(BOOST_INC_DIR)
-CXXFLAGS= -O0 -Wall
-LDFLAGS= -L$(BOOST_LIB_DIR) -lboost_thread-gcc43-mt -pthread
+CXXFLAGS= -O0 -Wall -std=c++0x
+LDFLAGS= -L$(BOOST_LIB_DIR) -lboost_thread -lboost_system -pthread
.PHONY: all clean dep test valgrind_test
all: $(PROGRAMS)
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