On Wed, 2014-02-19, Paavo Helde wrote:
> nvangogh <
nvan...@pcexpert.net> wrote in news:cn8Nu.5082$1B3...@fx26.am4:
...
>> bool find_value (vector<int>&, int);
...
> There are plenty of STL functions like std::sort() which take iterators as
> arguments, maybe you can take a look of their interfaces? BTW, your
> function appears to be already implemented as std::find(), with iterator
> arguments.
Except not returning a bool. I might write a small wrapper
(untested):
template<class It, class Val>
bool contains(It a, It b, const Val& val) {
return std::find(a, b, val)!=b;
}
Sometimes the code becomes much more readable as
if(contains(a, b, 42) && !contains(b, c, 96)) ...
instead of
if(std::find(a, b, 42)!=b && std::find(b, c, 96)==c) ...
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/
snipabacken.se> O o .