Brian Silverman | 355f11d | 2018-08-04 23:57:00 -0700 | [diff] [blame^] | 1 | // Boost shared_ptr_example2 header file -----------------------------------// |
| 2 | |
| 3 | // Copyright Beman Dawes 2001. Distributed under the Boost |
| 4 | // Software License, Version 1.0. (See accompanying file |
| 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | |
| 7 | |
| 8 | // See http://www.boost.org/libs/smart_ptr for documentation. |
| 9 | |
| 10 | #include <boost/shared_ptr.hpp> |
| 11 | |
| 12 | // This example demonstrates the handle/body idiom (also called pimpl and |
| 13 | // several other names). It separates the interface (in this header file) |
| 14 | // from the implementation (in shared_ptr_example2.cpp). |
| 15 | |
| 16 | // Note that even though example::implementation is an incomplete type in |
| 17 | // some translation units using this header, shared_ptr< implementation > |
| 18 | // is still valid because the type is complete where it counts - in the |
| 19 | // shared_ptr_example2.cpp translation unit where functions requiring a |
| 20 | // complete type are actually instantiated. |
| 21 | |
| 22 | class example |
| 23 | { |
| 24 | public: |
| 25 | example(); |
| 26 | void do_something(); |
| 27 | private: |
| 28 | class implementation; |
| 29 | boost::shared_ptr< implementation > _imp; // hide implementation details |
| 30 | }; |
| 31 | |