|
Boost : |
From: David A. Greene (greened_at_[hidden])
Date: 2002-12-05 15:56:40
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. 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. But I
don't think there's any way around that. MPL needs the same
thing for its placeholders. It just seems a shame that this
enumeration needs to be repeated for this special case when
it already exists for _1, _2, etc.
>>>I don't know... well, it could detect whether there was a ::type
>>>member, and if it were not present, it could just give you the outer
>>>class. I think that's a bit of a hack, though.
>>
>>Agreed. Urk...I'm not sure how to get around this problem without
>>requiring template template parameters (beyond what's used for
>>placeholders currently).
>
> There's no way. So what? Your compiler supports them.
Of course. But others don't. I'm more concerned about the duplication
of effort described above. But again, I don't think there's any way
around that.
-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