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_macros.h" 20 #include "test_iterators.h" 21 22 struct test1 23 { 24 TEST_CONSTEXPR bool operator()(const int& i) const 25 { 26 return i % 2 == 0; 27 } 28 }; 29 30 #if TEST_STD_VER > 17 31 TEST_CONSTEXPR bool test_constexpr() { 32 int ia[] = {1, 3, 6, 7}; 33 int ib[] = {1, 3, 5, 7}; 34 return !std::none_of(std::begin(ia), std::end(ia), test1()) 35 && std::none_of(std::begin(ib), std::end(ib), test1()) 36 ; 37 } 38 #endif 39 40 int main() 41 { 42 { 43 int ia[] = {2, 4, 6, 8}; 44 const unsigned sa = sizeof(ia)/sizeof(ia[0]); 45 assert(std::none_of(input_iterator<const int*>(ia), 46 input_iterator<const int*>(ia + sa), test1()) == false); 47 assert(std::none_of(input_iterator<const int*>(ia), 48 input_iterator<const int*>(ia), test1()) == true); 49 } 50 { 51 const int ia[] = {2, 4, 5, 8}; 52 const unsigned sa = sizeof(ia)/sizeof(ia[0]); 53 assert(std::none_of(input_iterator<const int*>(ia), 54 input_iterator<const int*>(ia + sa), test1()) == false); 55 assert(std::none_of(input_iterator<const int*>(ia), 56 input_iterator<const int*>(ia), test1()) == true); 57 } 58 { 59 const int ia[] = {1, 3, 5, 7}; 60 const unsigned sa = sizeof(ia)/sizeof(ia[0]); 61 assert(std::none_of(input_iterator<const int*>(ia), 62 input_iterator<const int*>(ia + sa), test1()) == true); 63 assert(std::none_of(input_iterator<const int*>(ia), 64 input_iterator<const int*>(ia), test1()) == true); 65 } 66 67 #if TEST_STD_VER > 17 68 static_assert(test_constexpr()); 69 #endif 70 } 71