mirror of
https://github.com/boostorg/signals.git
synced 2026-01-19 04:42:10 +00:00
Use unique_ptr instead of auto_ptr and bind instead bind1st where appropriate.
This commit is contained in:
@@ -72,7 +72,16 @@ namespace boost {
|
|||||||
// Allocate storage for an iterator that will hold the point of
|
// Allocate storage for an iterator that will hold the point of
|
||||||
// insertion of the slot into the list. This is used to later remove
|
// insertion of the slot into the list. This is used to later remove
|
||||||
// the slot when it is disconnected.
|
// the slot when it is disconnected.
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
|
|
||||||
std::auto_ptr<iterator> saved_iter(new iterator);
|
std::auto_ptr<iterator> saved_iter(new iterator);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
std::unique_ptr<iterator> saved_iter(new iterator);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// Add the slot to the list.
|
// Add the slot to the list.
|
||||||
iterator pos =
|
iterator pos =
|
||||||
@@ -133,7 +142,16 @@ namespace boost {
|
|||||||
signal_base_impl* self = reinterpret_cast<signal_base_impl*>(obj);
|
signal_base_impl* self = reinterpret_cast<signal_base_impl*>(obj);
|
||||||
|
|
||||||
// We won't need the slot iterator after this
|
// We won't need the slot iterator after this
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
|
|
||||||
std::auto_ptr<iterator> slot(reinterpret_cast<iterator*>(data));
|
std::auto_ptr<iterator> slot(reinterpret_cast<iterator*>(data));
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
std::unique_ptr<iterator> slot(reinterpret_cast<iterator*>(data));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// If we're flags.clearing, we don't bother updating the list of slots
|
// If we're flags.clearing, we don't bother updating the list of slots
|
||||||
if (!self->flags.clearing) {
|
if (!self->flags.clearing) {
|
||||||
|
|||||||
@@ -125,7 +125,16 @@ test_one_arg()
|
|||||||
boost::signal1<int, int, max_or_default<int> > s1;
|
boost::signal1<int, int, max_or_default<int> > s1;
|
||||||
|
|
||||||
s1.connect(std::negate<int>());
|
s1.connect(std::negate<int>());
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
|
||||||
|
|
||||||
s1.connect(std::bind1st(std::multiplies<int>(), 2));
|
s1.connect(std::bind1st(std::multiplies<int>(), 2));
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
s1.connect(std::bind(std::multiplies<int>(), 2, std::placeholders::_1));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOST_CHECK(s1(1) == 2);
|
BOOST_CHECK(s1(1) == 2);
|
||||||
BOOST_CHECK(s1(-1) == 1);
|
BOOST_CHECK(s1(-1) == 1);
|
||||||
@@ -143,8 +152,18 @@ test_signal_signal_connect()
|
|||||||
{
|
{
|
||||||
boost::signal1<int, int, max_or_default<int> > s2;
|
boost::signal1<int, int, max_or_default<int> > s2;
|
||||||
s1.connect(s2);
|
s1.connect(s2);
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
|
||||||
|
|
||||||
s2.connect(std::bind1st(std::multiplies<int>(), 2));
|
s2.connect(std::bind1st(std::multiplies<int>(), 2));
|
||||||
s2.connect(std::bind1st(std::multiplies<int>(), -3));
|
s2.connect(std::bind1st(std::multiplies<int>(), -3));
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
s2.connect(std::bind(std::multiplies<int>(), 2, std::placeholders::_1));
|
||||||
|
s2.connect(std::bind(std::multiplies<int>(), -3, std::placeholders::_1));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOST_CHECK(s2(-3) == 9);
|
BOOST_CHECK(s2(-3) == 9);
|
||||||
BOOST_CHECK(s1(3) == 6);
|
BOOST_CHECK(s1(3) == 6);
|
||||||
|
|||||||
@@ -123,7 +123,16 @@ test_one_arg()
|
|||||||
boost::signal<int (int value), max_or_default<int> > s1;
|
boost::signal<int (int value), max_or_default<int> > s1;
|
||||||
|
|
||||||
s1.connect(std::negate<int>());
|
s1.connect(std::negate<int>());
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
|
||||||
|
|
||||||
s1.connect(std::bind1st(std::multiplies<int>(), 2));
|
s1.connect(std::bind1st(std::multiplies<int>(), 2));
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
s1.connect(std::bind(std::multiplies<int>(), 2, std::placeholders::_1));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOST_CHECK(s1(1) == 2);
|
BOOST_CHECK(s1(1) == 2);
|
||||||
BOOST_CHECK(s1(-1) == 1);
|
BOOST_CHECK(s1(-1) == 1);
|
||||||
@@ -141,8 +150,18 @@ test_signal_signal_connect()
|
|||||||
{
|
{
|
||||||
boost::signal<int (int value), max_or_default<int> > s2;
|
boost::signal<int (int value), max_or_default<int> > s2;
|
||||||
s1.connect(s2);
|
s1.connect(s2);
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
|
||||||
|
|
||||||
s2.connect(std::bind1st(std::multiplies<int>(), 2));
|
s2.connect(std::bind1st(std::multiplies<int>(), 2));
|
||||||
s2.connect(std::bind1st(std::multiplies<int>(), -3));
|
s2.connect(std::bind1st(std::multiplies<int>(), -3));
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
s2.connect(std::bind(std::multiplies<int>(), 2, std::placeholders::_1));
|
||||||
|
s2.connect(std::bind(std::multiplies<int>(), -3, std::placeholders::_1));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOST_CHECK(s2(-3) == 9);
|
BOOST_CHECK(s2(-3) == 9);
|
||||||
BOOST_CHECK(s1(3) == 6);
|
BOOST_CHECK(s1(3) == 6);
|
||||||
|
|||||||
Reference in New Issue
Block a user