Boost logo

Boost :

From: David A. Greene (greened_at_[hidden])
Date: 2002-08-05 12:49:50

Jeremy Siek wrote:

> I'm having trouble understanding your example... would you mind doing
> another example, the car example from our NTP docs. That way it will be
> easier to compare. Also, having nice syntax is one of the major concerns
> of this library, so it is hard to disregard it as you ask. Perhaps in this
> next example you could also improve to what you think is the best syntax
> for your approach...

Ok, that sounds reasonable. I've attached a revised example. This
doesn't have all of the functionality of the sandbox car example.
It's missing the ability to distinguish NTPs from "regular"
parameters and the type-dependent default for the seats parameter.
Both of these, however, are orthogonal to the NTP mechanism in that
the same approaches given in the sandbox example can be used in
the example I present here. I just haven't coded up the support yet.

The example includes a car structured as taking a typelist of
NTPs and a car taking individual scalar NTPs as in the sandbox
example. I was quite pleased at how easy it was to implement the
latter on top of the former.

I can't say that this is the best syntax. It's a stab at a better
syntax, but part of the reason I'm posting this is to get ideas.
It still needs to be ported to MPL. I'm waiting to see whether
MPL is accepted and for an official release assuming that happens.

I see two main advantages to this alternate approach:

- Declaration of parameters and defaults is decoupled from
   the binding of parameters to defaults. No car_defaults is
   necessary though it could of course be used for convenience.
   Model_is, etc. are replaced by the "standard" ntp<> class.

- The use of typelists allows an arbitrary number of template
   parameters. I can't say with absolute certainty until I play
   around with this some more, but I think I can get all of the
   functionality of the sandbox NTP with the typelist mechanism.

Thanks for your thoughts!


"Some little people have music in them, but Fats, he was all music,
  and you know how big he was."  --  James P. Johnson

Boost list run by bdawes at, gregod at, cpdaniel at, john at