Boost logo

Boost :

Subject: Re: [boost] [Review] Reminder: Boost.RangeEx review is going on
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-03-02 13:44:44


----- Original Message -----
From: "Steven Watanabe" <watanabesj_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, March 02, 2009 4:32 PM
Subject: Re: [boost] [Review] Reminder: Boost.RangeEx review is going on

>
> AMDG
>
> vicente.botet wrote:
>> why do we need two overloading for the non mutating algorithms? I understand the issue for mutatong algorithms, but the parameter is not always const for non mutating ones?
>>
>> template<class ForwardRange>
>> typename range_iterator<ForwardRange>::type
>> adjacent_find(ForwardRange& rng);
>>
>> template<class ForwardRange>
>> typename range_iterator<const ForwardRange>::type
>> adjacent_find(const ForwardRange& rng);
>>
>
> For the same reason that we have const and non-const overloads
> of begin(), end(), operator[], etc. We may need mutating access
> through the result.

Thanks Steven,

I have not chooen the good example.

Should we have two overloadings for count?

   template< class SinglePassRange, class Value >
    inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange>::type
    count(SinglePassRange& rng, const Value& val)
    {
        boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
        return std::count(boost::begin(rng), boost::end(rng), val);
    }

    /// \overload
    template< class SinglePassRange, class Value >
    inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange const>::type
    count(const SinglePassRange& rng, const Value& val)
    {
        boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
        return std::count(boost::begin(rng), boost::end(rng), val);
    }

Vicente


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