Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-02-14 17:37:36


Jason Hise wrote:
> In my singleton code, I have been using a template template parameter
> in my lifetimes for the creator[1], so that client code does not need to
> duplicate writing the type when specifying the creation policy.

> As an alternative, I am thinking of switching the creator policy to a
> non template template policy. Although this would make client code
> have
> to plug the name of their class into the base singleton template yet a
> third time, I am thinking that in the end it would be more portable
> and cleaner. Thoughts?

I suggested you follow policy_ptr and use mpl metafunction classes as policy
template parameters. See, for instance, the array storage policy:
http://tinyurl.com/6tbhu.

It looks like this:

    template <typename T>
    class array_storage_
    { ... };

    struct array_storage
    {
        typedef storage_policy_tag policy_category;

        template <typename T>
        struct apply
        {
            typedef array_storage_<T> type;
        };
    };

Jonathan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk