Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-06-18 18:07:10


Ryan Gallagher <ryan.gallagher_at_[hidden]> writes:

> Brian Braatz <brianb <at> rmtg.com> writes:
>
>>
>> CLOSER (see below)
>>
>> > On Behalf Of Ryan
>> > [snip]
>> > Try:
>> >
>> > typedef mpl::copy
>> > <
>> > mpl::begin<myset>
>> > , mpl::back_inserter<vec>
>> > >::type result_vec;
>> >
>> > HTH
>> >
>> > -Ryan
>> >
>>
>> [Brian Braatz Writes:]
>> THANK YOU RYAN- I am compiling now (one step closer)
>> But I am still not getting the expected (??) behavior
>> here is the current code
>> ...
>
> Sorry about the leading you down the wrong path Brian. I was really thinking
> about:
>
> typedef mpl::copy
> <
> mpl::iterator_range<mpl::begin<myset>::type, mpl::end<myset>::type >
> , mpl::back_inserter< vec >
> >::type result_vec;
>
> which would only be a work around but IMO is more similar to the runtime
> equivalent.

Not really. copy just works on a pair of iterators anyway, under the
covers.

> I am a little suprised the mpl::begin<> compiled, but I need to
> review Dave's and Alesky's MPL book again and will hopefully come to
> understand.

Well, mpl::begin<myset> is just a type like any other. You haven't
even instantiated it. But the copy<mpl::begin<myset>, ...> may have
compiled because of the peculiar way in which set iterators were
broken: deref<begin<myset>::type>::type was always myset (or
the equivalent set3<...> with the same elements).

> I was actually on the newsgroup yesterday to see the answer to your
> great remove_duplicate_types question. I had just written the
> equivalent runtime function using std::vector, std::sort, and
> std::unique and was wondering about how to handle std::sort in the
> compile_time world. I stopped on this thread because I saw that it
> could likely lead to the answer.

http://www.boost.org/libs/mpl/doc/refmanual/sort.html

;^)

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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