]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/signals2/test/dead_slot_test.cpp
1 // Boost.Signals library
3 // Copyright (C) Douglas Gregor 2001-2006. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see http://www.boost.org
10 #include <boost/bind/bind.hpp>
11 #include <boost/shared_ptr.hpp>
12 #include <boost/signals2.hpp>
13 #define BOOST_TEST_MODULE dead_slot_test
14 #include <boost/test/included/unit_test.hpp>
16 using namespace boost::placeholders
;
18 typedef boost::signals2::signal
<int (int)> sig_type
;
22 with_constant(int c
) : constant(c
) {}
24 int add(int i
) { return i
+ constant
; }
30 void do_delayed_connect(boost::shared_ptr
<with_constant
> &wc
,
32 sig_type::slot_type slot
)
34 // Should invalidate the slot, so that we cannot connect to it
37 boost::signals2::connection c
= sig
.connect(slot
);
38 BOOST_CHECK(!c
.connected());
41 BOOST_AUTO_TEST_CASE(test_main
)
44 boost::shared_ptr
<with_constant
> wc1(new with_constant(7));
46 do_delayed_connect(wc1
, s1
, sig_type::slot_type(&with_constant::add
, wc1
.get(), _1
).track(wc1
));