Boost logo

Boost :

From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-04-06 16:53:30


I think that I start to understand.

_____________________
Vicente Juan Botet Escriba

----- Original Message -----
From: "shunsuke" <pstade.mb_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Sunday, April 06, 2008 8:55 PM
Subject: Re: [boost] Egg 2nd request for reviews: Some comments

> vicente.botet wrote:
>> Could you tell me if the following is equivalent to what appears in the
>> quick start. I'm not very confortable with
>> foreach.
>>
>> </code>
>> template<class Range, class Predicate>
>> struct mono_make_filtered
>> {
>> typedef
>> boost::filter_iterator<
>> typename boost::remove_cv<Predicate>::type,
>> typename boost::range_result_iterator<Range>::type
>> >
>> iter_t;
>>
>> typedef
>> boost::iterator_range<iter_t>
>> result_type;
>>
>> result_type operator()(Range &rng, Predicate &pred) const
>> {
>> return result_type(
>> iter_t(pred, boost::begin(rng), boost::end(rng)),
>> iter_t(pred, boost::end(rng), boost::end(rng))
>> );
>> }
>> };
>>
>> bool is_not_X(char ch) { return ch != 'X'; }
>> bool is_not_Y(char ch) { return ch != 'Y'; }
>> bool is_lower(char ch) { return std::islower(ch, std::locale()); }
>>
>> void quick_start_make_filtered()
>> {
>> std::string src("abXcYdXefXgYhY");
>>
>> mono_make_filtered::result_type lowers = make_filtered(src,
>> &is_lower);
>>
>> foreach (char ch, lowers) {
>> std::cout << ch;
>> }
>>
>> foreach (char ch, make_filtered(make_filtered(src, &is_not_X),
>> &is_not_Y)) {
>> std::cout << ch;
>> }
>> }
>> </code>
>>
>> If this is the case could you show which is really the advantage to use
>> Egg.
>> I 'm sure there are a lot of, but I think the example do not show them.
>
> No, it's not equivalent.
> mono_make_filtered<std::string, bool(*)(char)>::result_type lowers = ...
> is equivalent, though.
> A problem of this form is that
> users of `make_filtered` have to remember the usage of
> `mono_make_filtered`
> instead of the standardized metafunction `result_of`.
>
>
>
> Regards,
>
> --
> Shunsuke Sogame
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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