postconstructible.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // DEPRECATED in favor of adl_postconstruct with deconstruct<T>().
  2. // A simple framework for creating objects with postconstructors.
  3. // The objects must inherit from boost::signals2::postconstructible, 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_POSTCONSTRUCTIBLE_HPP
  15. #define BOOST_SIGNALS2_POSTCONSTRUCTIBLE_HPP
  16. namespace boost
  17. {
  18. template<typename T> class shared_ptr;
  19. namespace signals2
  20. {
  21. namespace postconstructible_adl_barrier
  22. {
  23. class postconstructible;
  24. }
  25. namespace detail
  26. {
  27. void do_postconstruct(const boost::signals2::postconstructible_adl_barrier::postconstructible *ptr);
  28. } // namespace detail
  29. namespace postconstructible_adl_barrier
  30. {
  31. class postconstructible
  32. {
  33. public:
  34. friend void detail::do_postconstruct(const postconstructible *ptr);
  35. template<typename T>
  36. friend void adl_postconstruct(const shared_ptr<T> &, postconstructible *p)
  37. {
  38. p->postconstruct();
  39. }
  40. protected:
  41. postconstructible() {}
  42. virtual ~postconstructible() {}
  43. virtual void postconstruct() = 0;
  44. };
  45. } // namespace postconstructible_adl_barrier
  46. using postconstructible_adl_barrier::postconstructible;
  47. }
  48. }
  49. #endif // BOOST_SIGNALS2_POSTCONSTRUCTIBLE_HPP