|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2002-12-05 23:32:14
"David A. Greene" <greened_at_[hidden]> writes:
> David Abrahams wrote:
>
>>>Your correction above makes everything clear to me now.
>> So do you feel you need an additional library feature? ;-)
>
> I suppose not. What I really wanted was the ability to take a
> regular old template class and create a generator out of it:
>
> template<typename T, typename U, typename V>
> struct my_type { ... } // Note: no ::type member
>
> typedef SHAZAM<my_type<int, _1, _2> > generator;
>
> typedef generator::template apply<char, float>::type my_type_inst;
>
> I want SHAZAM to be generic enough to take any template class,
> not just my_type.
You can do that, up to N arguments, for some N.
> If I understand your solution correctly,
> it requires a manually-constructed generator for my_type:
>
> template<typename T, typename U, typename V>
> struct my_type_generator {
> typedef my_type<T, U, V> type;
> };
>
> SHAZAM then becomes mpl::lambda.
>
> The problem is, I'll have to create these trivial "generators"
> (I hesitate to even call it that) many times over, once for each
> class I want to bind.
>
> But I can construct a generic trivial generator:
>
> template<template<typename A, typename B, typename C> class Base,
> typename T, typename U, typename V>
> struct trivial_generator {
> typedef Base<T, U, V> type;
> };
>
> Then I can use MPL lambda facilities. Unfortunately, I need a
> trivial_generator for every arity of class template.
Only as part of the implementation. You just need a nice wrapper over
the top to hide it all.
-- David Abrahams dave_at_[hidden] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk