Boost logo

Boost :

From: David A. Greene (greened_at_[hidden])
Date: 2002-08-04 14:07:52


I just saw the note about the named template parameter library
in the sandbox. I checked it out and it looks very nice!

I've taken a somewhat different approach in my NTP implementation.
The library in the sandbox is "intrusive" in that it requires the
user to define classes like car_defaults and Model_is (from the
example in the documentation).

My implementation allows any class to act as a default for
a template argument. A map_param utility class takes care
of the associations. This is a more generic version of Model_is,
etc. Thus the user can define parameter tags (analogous to
parts of Model_is) and default values and mix them freely.

My version uses typelists to allow an arbitrary number of
template parameters. This is quite useful when policies are
involved.

I've attached an example of usage. Please disregard the ugly
syntax for a moment. It's a result of playing around with
metaprogramming, wrapping metafunctions, etc. I'm going to
port this thing to MPL eventually. I've added some comments
proposing a simpler alternative syntax, but that's a quick
one-off job. Lots of work is needed here.

The general idea is that the user provides a list of parameter
tag/type pairs and the class given this list uses the NTP engine
to extract the parameters. It's a compile-time parameter map,
in other words.

This won't compile because it's missing important header files.
I'm just attaching it to gague how useful this might be to
folks here. This is all very, very preliminary. It might be
overkill.

Comments/criticisms welcome. :)

                        -Dave

-- 
"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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk