[Home]STLAlgorithmExtensions/AllAlgorithm

BOOST WIKI | STLAlgorithmExtensions | RecentChanges | Preferences | Page List | Links List

Showing revision 4
This algorithm returns true if the predicate is true for all elements in the range.
template <typename InputIterator, typename Predicate>
bool all(InputIterator first, InputIterator last, Predicate p)
{
  for (; first != last; ++first)
    if (!p(*first))
      return false;
  return true;
}

Couldn't this be more simply stated as:
template <typename InputIterator, typename Predicate>
bool all_if(InputIterator first, InputIterator last, Predicate p) {
  return std::find_if(first, last, std::not1(p)) == last;
}

?



BOOST WIKI | STLAlgorithmExtensions | RecentChanges | Preferences | Page List | Links List
Edit revision 4 of this page | View other revisions | View current revision
Edited July 23, 2004 3:10 pm (diff)
Search:
Disclaimer: This site not officially maintained by Boost Developers