|
Boost : |
From: Howard Hinnant (hinnant_at_[hidden])
Date: 2003-01-31 14:47:37
On Friday, January 31, 2003, at 12:54 PM, Jonathan Wang wrote:
> The default features(types) are stored in a type-vector, and we can
> use boost.mpl to update the default features into use-defined ones,
> and to extract the updated paramters from type-vector. Then we can use
> NTPs later. And even can we mix the NTPs and the ordinary paramters,
> just to use ntp::update2 instead of ntp::update.
I've also looked at ntp implementation similar to this (but used Loki
type lists), and agree that this is a neat way to go. Essentially you
just stick the defaults onto the end of the type list. Then if the
user specifies anything, either by a default tag, a named parameter, or
a positional parameter, you prepend it to the type list. Then the
extraction routine simply searches the type list for the first
appropriate parameter.
Another thing this approach affords is relatively easy error checking.
It is possible the user may accidently specify a parameter more than
once (especially when you mix positional and named parameters). It is
easy to search the type list and make sure that a parameter is not
specified more than twice (once for the default, and not more than once
for a user-supplied input).
-Howard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk