Listing 2: The resource_manager class in action.
template <class storage_policy, class ownership_policy> class resource_manager : public optimally_inherit<storage_policy, ownership_policy>::type { ... ~resource_manager() { if (!ownership_policy::release(get_impl(*this))) { storage_policy::release(); } } }; template < typename T, template <typename> class ownership_policy = ref_counted, template <typename> class conversion_policy = disallow_conversion, template <typename> class checking_policy = assert_check, template <typename> class storage_policy = scalar_storage> class smart_ptr : public optimally_inherit< resource_manager< storage_policy<T>, ownership_policy<T> >, optimally_inherit< checking_policy<T>, conversion_policy<T> > > { ... };