Boost logo

Boost :

From: Spencer Collyer (spencer_at_[hidden])
Date: 2006-02-02 06:03:07


On Wed, 01 Feb 2006 17:14:59 +0100, Sebastian Redl wrote:
> This looks like a very nice utility, and I'm sure it could find
> application. A library facing a similar problem is the iterator
> library, where the use_default mechanism was used. In this particular
> case, however, your method is not applicable as it is, because the
> parameters specified by use_default can be primitives.

I designed PolicySelector to work with policy classes, so didn't think
about primitive types when writing it.

> An alternative to the inheritance would be a policy_type metafunction:

I'll need to study the code you presented a bit more to understand it.
The way I saw it working was that, if the user had some pre-existing
policy class they wanted to use, they could wrap it up in another class
that inherited from the base class, and just forwarded all operations on.
Given I like to keep interfaces to policy classes small, this didn't seem
too much of an overhead to me.

>
> A_Selector thus becomes:
> =============================================
> template< typename Policies >
> struct A_Selector
> {
> typedef typename PolicySelector< a_policy, Policies, a3>::type type;
> // I don't know why you had Types::type here in your example.
> };
> =============================================

If I didn't have the 'typename Types::type' in the selectors, the code
didn't work - it always gave the default. An alternative would have been
to put it in the PolicySelector itself, which probably would make future
users' lives easier. If it looks like there is more interest in this,
I'll make that change and send a modified example to the list.

Thanks for the feedback.

Spencer Collyer

-- 
10:49am up 49 days 18:31, 20 users, load average: 0.10, 0.11, 0.38
Registered Linux User #232457 | LFS ID 11703

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