Boost logo

Boost :

From: Michiel Salters (Michiel.Salters_at_[hidden])
Date: 2002-02-21 04:34:22

> -----Original Message-----
> From: David Abrahams [mailto:david.abrahams_at_[hidden]]
> Sent: dinsdag 19 februari 2002 23:48
> To: boost_at_[hidden]
> Subject: Re: [boost] Re: Most needed/desired features in C++

> > --- In boost_at_y..., Carl Daniel <cpdaniel_at_p...> wrote:
> > > I'd like to see the rule for template template argument
> > compatibility relaxed (e.g. such that std::vector<T,A=allocator>
> > > and myclass<T> would both be compatible with a template template
> > parameter declared as template <class>). The current
> > > rule appears to have been adopted to better meet with users
> > expectations (as compared to function pointer
> > > compatibility). The not-infrequent threads on c.l.c++.m
> about this
> > subject suggest that it did just the opposite:
> > > institutionalized behavior which is counter to expectations and
> > unnecessarily limiting.

> FWIW, both gcc and Borland "work" the way you'd like, and
> that bug cripples
> meta-lambda expressions in MPL on those compilers. Before you
> buy into this
> change you should consider this example Aleksey sent me today:
> -------
> template< template<typename> class F > struct my {};
> template<typename T, typename U = T> struct her {};
> int main()
> {
> sizeof(my<her>); // should not compile, but ok with
> GCC/Borland
> return 0;
> }

What's the point of this example ?
I don't see why this is a counter-argument to the proposal; her<> is a
which can be instantiated with one or two type parameters. my<> is a
template that can be instantiated with another template F capable of taking
one parameter. Presumably, my is going to instantiate F<X> for some X.
Taking these two together, I say template her matches the requirements
of my; you can instantiate her<X> in my<her>.

My current solution is
template<typename T> class her_wrapper : public her<T>, which is usually
good enough. But since it technically introduces new types, a number of
idioms fail. E.g. max( her_wrapper<T>,her<T,T>) doesn't exist.

Michiel Salters     Consultant Software Engineering

Boost list run by bdawes at, gregod at, cpdaniel at, john at