199b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com//===----------------------------------------------------------------------===// 299b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com// 399b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com// The LLVM Compiler Infrastructure 499b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com// 599b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com// This file is dual licensed under the MIT and the University of Illinois Open 699b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com// Source Licenses. See LICENSE.TXT for details. 799b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com// 899b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com//===----------------------------------------------------------------------===// 999b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com 1099b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com// <algorithm> 1199b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com 1299b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com// template <class InputIterator, class Predicate> 1399b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com// bool 1499b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com// all_of(InputIterator first, InputIterator last, Predicate pred); 1599b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com 1699b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com#include <algorithm> 1799b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com#include <cassert> 1899b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com 1999b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com#include "test_iterators.h" 2099b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com 2199b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.comstruct test1 2299b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com{ 2399b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com bool operator()(const int& i) const 24bdf981cb383b7ec472ee86d2fedb53937285f894rtoy@google.com { 25bdf981cb383b7ec472ee86d2fedb53937285f894rtoy@google.com return i % 2 == 0; 2699b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com } 2799b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com}; 2899b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com 2999b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.comint main() 3099b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com{ 3199b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com { 3299b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com int ia[] = {2, 4, 6, 8}; 3399b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com const unsigned sa = sizeof(ia)/sizeof(ia[0]); 3499b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com assert(std::all_of(input_iterator<const int*>(ia), 3599b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com input_iterator<const int*>(ia + sa), test1()) == true); 3699b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com assert(std::all_of(input_iterator<const int*>(ia), 3799b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com input_iterator<const int*>(ia), test1()) == true); 3899b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com } 3999b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com { 4099b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com const int ia[] = {2, 4, 5, 8}; 4199b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com const unsigned sa = sizeof(ia)/sizeof(ia[0]); 4299b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com assert(std::all_of(input_iterator<const int*>(ia), 4399b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com input_iterator<const int*>(ia + sa), test1()) == false); 4499b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com assert(std::all_of(input_iterator<const int*>(ia), 4599b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com input_iterator<const int*>(ia), test1()) == true); 4699b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com } 4799b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com} 4899b31ea5d0f4629ceddf4852f96757c9c73654artoy@google.com