scoped_ptr_example.hpp 951 B

1234567891011121314151617181920212223242526272829
  1. // Boost scoped_ptr_example header file ------------------------------------//
  2. // Copyright Beman Dawes 2001. Distributed under the Boost
  3. // Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/smart_ptr for documentation.
  6. #include <boost/utility.hpp>
  7. #include <boost/scoped_ptr.hpp>
  8. // The point of this example is to prove that even though
  9. // example::implementation is an incomplete type in translation units using
  10. // this header, scoped_ptr< implementation > is still valid because the type
  11. // is complete where it counts - in the inplementation translation unit where
  12. // destruction is actually instantiated.
  13. class example : private boost::noncopyable
  14. {
  15. public:
  16. example();
  17. ~example();
  18. void do_something();
  19. private:
  20. class implementation;
  21. boost::scoped_ptr< implementation > _imp; // hide implementation details
  22. };