shared_ptr_example2.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. // Boost shared_ptr_example2 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/shared_ptr.hpp>
  7. // This example demonstrates the handle/body idiom (also called pimpl and
  8. // several other names). It separates the interface (in this header file)
  9. // from the implementation (in shared_ptr_example2.cpp).
  10. // Note that even though example::implementation is an incomplete type in
  11. // some translation units using this header, shared_ptr< implementation >
  12. // is still valid because the type is complete where it counts - in the
  13. // shared_ptr_example2.cpp translation unit where functions requiring a
  14. // complete type are actually instantiated.
  15. class example
  16. {
  17. public:
  18. example();
  19. void do_something();
  20. private:
  21. class implementation;
  22. boost::shared_ptr< implementation > _imp; // hide implementation details
  23. };