]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/signals2/example/predestructor_example.cpp
1 // Minimal example of defining a predestructor for a class which
2 // uses boost::signals2::deconstruct as its factory function.
4 // Copyright Frank Mori Hess 2009.
6 // Use, modification and
7 // distribution is subject to the Boost Software License, Version
8 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10 // For more information, see http://www.boost.org
12 #include <boost/shared_ptr.hpp>
13 #include <boost/signals2/deconstruct.hpp>
16 namespace bs2
= boost::signals2
;
25 std::cout
<< "cruel world!" << std::endl
;
27 /* This adl_predestruct friend function will be found by
28 via argument-dependent lookup when using boost::signals2::deconstruct. */
29 friend void adl_predestruct(X
*)
31 std::cout
<< "Goodbye, ";
33 /* boost::signals2::deconstruct always requires an adl_postconstruct function
34 which can be found via argument-dependent, so we define one which does nothing. */
35 template<typename T
> friend
36 void adl_postconstruct(const boost::shared_ptr
<T
> &, X
*)
39 friend class bs2::deconstruct_access
; // give boost::signals2::deconstruct access to private constructor
40 // private constructor forces use of boost::signals2::deconstruct to create objects.
49 boost::shared_ptr
<mynamespace::X
> x
= bs2::deconstruct
<mynamespace::X
>();