Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-02-28 12:19:38


AMDG

Scott Meyers wrote:
> Steven Watanabe wrote:
>
>> template<class Sequence>
>> struct MakeFeatures {
>> typedef Features<typename copy<Sequence, back_inserter<vector0<> >
>> >::type> type;
>> };
>>
>
> I'm trying to understand the code you posted, but I'm having trouble, probably
> because I'm missing some basic concepts. I hope people here won't mind helping
> me with something I'm sure is basic: why do we need to make a copy of Sequence
> here? I've tried replacing the above typedef with
>
> typedef Features<Sequence> type;
>
> and everything breaks, so it's clear that the copy is there for a reason, but
> what is it?
>

The copy is to guarantee uniqueness. If you have a
Features<mpl::list<...> > this will not be the same as
a Features<mpl::vector<...> >. The mpl::copy<>
makes sure that Features<> always holds a type built
by push_back on vector0<>. Thus, MakeFeatures<mpl::list<int, char,
double> >::type
is the same as MakeFeatures<mpl::vector<int, char double> >::type.
Does that help?

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net