Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2001-06-25 15:31:43


Vesa Karvonen wrote:

>
> Anyway, I'm interested in seeing plausible uses of template template
> parameters. I think that this subject might be more appropriate for a C++
> newsgroup, except that I'm mainly interested in seeing actual use of template
> template parameters in existing libraries.

The smart pointer garbage collection classes in the zip files in:
   http://groups.yahoo.com/group/boost/files/GarbageCollectByTmplSpecializa/
use template template parameters. I'd be interested in knowing if they can
be avoided.

>
> ...
>
> At least in template metaprogramming, template template parameters seem to
> have limited use and member templates seem much more powerful. The only truly
> plausible "use" I know of, is that of adapting a metafunction into a
> "metafunction object" (is there a better name for this concept?):
>
> template
> < template<class> class fun
> >
> struct make_fun_obj
> { template
> < class T
> >
> struct code : fun<T>
> {
> };
> };
>
> Metafunction objects, which rely on member templates make it possible to:
> - bind parameters (and curry):
>
> template
> < class fun_obj
> , class p1
> >
> struct bind_2nd
> { template
> < class p0
> >
> struct code : fun_obj::template code<p0,p1>
> {
> };
> };
>
> - return a metafunction object or store it in a type data structure.
>
> These techniques are quite powerful. For instance, I'm using lists that

This technique was also used in the subjprox_vec and subjprox_one templates
in GarbageCollectByTmplSpecializa to enable the smart pointer analog to
vector of vectors and pointers to pointers.


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