Boost logo

Boost :

Subject: Re: [boost] [Algorithm] contains(v, 1)
From: Robert Ramey (ramey_at_[hidden])
Date: 2018-06-02 19:35:40


On 6/2/18 2:17 AM, Devika Krishnadas via Boost wrote:
> I do not know how relevant this is, but as a competitive programmer, it is
> our usual practice to use #defines to make our lives easier.
> For such a case, we use #define all(v) v.begin(),v.end()
> And now any function call can just be as the following example -
> sort(all(v))
> Or
> contains(all(v),Val)
>
> I'm sorry if this is irrelevant.

LOL - irrelevance is not a reason to avoid posting here.

But this raises another interesting question. How about something like:

template<class F, class C>
auto range_adaptor(const C & c){
        return F(c.begin(), c.end());
}

so one could say

vector<int> v = ...

range_adapt(std::find, v);

for any collection type.

Robert Ramey


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