Boost logo

Boost :

From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2002-08-08 14:08:41


Hi Iain,

> I'm not sure if I understand this correctly, but it looks to me that you
> could instanciate the following types of car:
>
> car< red, blue, black, red > my_very_strange_car;

Sure you can, and you get a car like:

model: red
color: blue
seats: black
transmission: red

assuming that all parameter positions accept either a named or unnamed
template parameters.

(The test program doesn't and it does in deed behave a bit strangely,
because of what you pointed out next):

> This does not seem very desireable. Also, shouldn't the
> named_parameter_exctractor use is_named_parameter to check that a user
> supplied parameter is a named parameter.

Yes, this makes sense. I'll add this test.

Getting back to car<red, blue, black, red> my_very_strange_car

Your real car template would do something meaningful with its template
parameters, and would reject such instantiation at some point.
Our empty car template has no requirements for its template parameters,
making this code valid. The NTP mechanism doesn't, and shouldn't, have any
criteria for accepting certain types and rejecting others. This is the
task of the car template itself, once the NTP has figured out what all
the parameters (or features) are.

> I don't understand why the class discriminator needs to virtually inherit?
> As far as I can see, even if the user instanciated car with duplicate types
> or the implementer of car used duplicate types, the recursive feature
> selector will always provide a different integer value.

Could be, I have to check, but virtual inheritance doesn't do any harm
either.

> You can't do GenVoca layering with it to create communicating policies, and
> you can't use a parameter to inject a member function into the class. It is
> also going to require an instance variable for each
> named_template_parameter.

Could you elaborate, with examples, all these three points.

> Personally found it less intuative than the 'C & E' named template
> parameters and it seems to be at least as verbose.

What was the 'C & E' NTP solution again?

Cheers, Jaakko


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