predestructible.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // DEPRECATED in favor of adl_predestruct with deconstruct<T>().
  2. // A simple framework for creating objects with predestructors.
  3. // The objects must inherit from boost::signals2::predestructible, and
  4. // have their lifetimes managed by
  5. // boost::shared_ptr created with the boost::signals2::deconstruct_ptr()
  6. // function.
  7. //
  8. // Copyright Frank Mori Hess 2007-2008.
  9. //
  10. //Use, modification and
  11. // distribution is subject to the Boost Software License, Version
  12. // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_SIGNALS2_PREDESTRUCTIBLE_HPP
  15. #define BOOST_SIGNALS2_PREDESTRUCTIBLE_HPP
  16. namespace boost
  17. {
  18. namespace signals2
  19. {
  20. template<typename T> class predestructing_deleter;
  21. namespace predestructible_adl_barrier
  22. {
  23. class predestructible
  24. {
  25. protected:
  26. predestructible() {}
  27. public:
  28. template<typename T>
  29. friend void adl_postconstruct(const shared_ptr<T> &, ...)
  30. {}
  31. friend void adl_predestruct(predestructible *p)
  32. {
  33. p->predestruct();
  34. }
  35. virtual ~predestructible() {}
  36. virtual void predestruct() = 0;
  37. };
  38. } // namespace predestructible_adl_barrier
  39. using predestructible_adl_barrier::predestructible;
  40. }
  41. }
  42. #endif // BOOST_SIGNALS2_PREDESTRUCTIBLE_HPP