PrevUpHomeNext

Customization

Previously mentioned Pimpl class definitions

struct Book : boost::impl_ptr<Book>::shared { ... };
struct Book : boost::impl_ptr<Book>::unique { ... };
struct Book : boost::impl_ptr<Book>::copied { ... };

use shared, unique, copied as base classes. Those are, in fact, shorthand aliases to abbreviate the basic default deployment of the respective policies. When specified explicitly, the definitions look as follows:

using policy = impl_ptr_policy;

struct Book : boost::impl_ptr<Book, policy::shared> { ... };
struct Book : boost::impl_ptr<Book, policy::unique> { ... };
struct Book : boost::impl_ptr<Book, policy::copied> { ... };

That direct form allows far greater flexibility, policy customization and configurability. Now custom policies are easily deployed:

template<typename impl_type, typename... more_types>
struct my_policy { ... };

struct Book : boost::impl_ptr<Book, my_policy> { ... };

Then, policies are easily configured:

struct Book : boost::impl_ptr<Book, policy::shared, my_allocator> { ... };
struct Book : boost::impl_ptr<Book, policy::unique, my_allocator> { ... };
struct Book : boost::impl_ptr<Book, policy::copied, my_allocator> { ... };
struct Book : boost::impl_ptr<Book, policy::inplace, policy::storage<64>> { ... };

PrevUpHomeNext