Home | History | Annotate | Download | only in alg.none_of
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <algorithm>
     11 
     12 // template <class InputIterator, class Predicate>
     13 //   bool
     14 //   none_of(InputIterator first, InputIterator last, Predicate pred);
     15 
     16 #include <algorithm>
     17 #include <cassert>
     18 
     19 #include "test_iterators.h"
     20 
     21 struct test1
     22 {
     23     bool operator()(const int& i) const
     24     {
     25         return i % 2 == 0;
     26     }
     27 };
     28 
     29 int main()
     30 {
     31     {
     32         int ia[] = {2, 4, 6, 8};
     33         const unsigned sa = sizeof(ia)/sizeof(ia[0]);
     34         assert(std::none_of(input_iterator<const int*>(ia),
     35                             input_iterator<const int*>(ia + sa), test1()) == false);
     36         assert(std::none_of(input_iterator<const int*>(ia),
     37                             input_iterator<const int*>(ia), test1()) == true);
     38     }
     39     {
     40         const int ia[] = {2, 4, 5, 8};
     41         const unsigned sa = sizeof(ia)/sizeof(ia[0]);
     42         assert(std::none_of(input_iterator<const int*>(ia),
     43                             input_iterator<const int*>(ia + sa), test1()) == false);
     44         assert(std::none_of(input_iterator<const int*>(ia),
     45                             input_iterator<const int*>(ia), test1()) == true);
     46     }
     47     {
     48         const int ia[] = {1, 3, 5, 7};
     49         const unsigned sa = sizeof(ia)/sizeof(ia[0]);
     50         assert(std::none_of(input_iterator<const int*>(ia),
     51                             input_iterator<const int*>(ia + sa), test1()) == true);
     52         assert(std::none_of(input_iterator<const int*>(ia),
     53                             input_iterator<const int*>(ia), test1()) == true);
     54     }
     55 }
     56