(The revisions are identical or unavailable.)

This algorithm is analogous to the std::bitset::any() function, but applied to a generic range. The algorithm returns true if the predicate it true for any element in the range.

template <typename InputIterator, typename Predicate> bool any_if(InputIterator first, InputIterator last, Predicate p) { return std::find_if(first, last, p) != last; }

I realise this is moot point, but isn't "exists" a better name? This question is related to STLAlgorithmExtensions/ExistsAndOnlyAlgorithm.

- People/Vladimir Prus

I was thinking about this on my walk into work today :) "exists" is certainly more correct mathematically, though I'm not sure your average user would be as comfortable with "exists" as with "any". --People/JeremySiek

Hard to tell. Probably that average users should step forward and express their preferences. I'm not sure they will, however. --People/Vladimir Prus

I prefer "exists".

A ++ for exists from me.

I vote for "exists" also. -- Kevin S. Van Horn

A new contender! I would prefer contains_if, extending the proposed contains algorithm in a similar way to STL remove_if etc. -- Alisdair Meredith

I'd prefer "some", for grammatical reasons. For all x, for some x, ... -- Richard Copley

To me, "exists" sounds more like a search algorithm, whereas we are just testing a condition here. Comparing (given "For all x") "for some x" with "for any x", I prefer to say "for any x". Code might look like (please feel free to add to this list):

if ( all_if(beg,end,p) ) ... if ( any_if(beg,end,p) ) ... if ( any_of(beg,end,p) ) ... if ( any(beg,end,p) ) ... if ( some_if(beg,end,p) ) ... if ( exists_if(beg,end,p) ) ... if ( exists(beg,end,p) ) ...I don't like "some". For consistency with std, _if is probably better. I think any_if matches best to all_if in my mind. -- cheers, Zenaan

Disclaimer: This site not officially maintained by Boost Developers