int main() { int ia[] = {0, 1, 2, 3, 4, 5}; const unsigned s = sizeof(ia)/sizeof(ia[0]); for_each_test f = std::for_each(input_iterator<int*>(ia), input_iterator<int*>(ia+s), for_each_test(0)); assert(f.count == s); for (unsigned i = 0; i < s; ++i) assert(ia[i] == i+1); }
int main(int, char**) { typedef input_iterator<int*> Iter; int ia[] = {0, 1, 2, 3, 4, 5}; const unsigned s = sizeof(ia)/sizeof(ia[0]); { auto f = for_each_test(0); Iter it = std::for_each_n(Iter(ia), 0, std::ref(f)); assert(it == Iter(ia)); assert(f.count == 0); } { auto f = for_each_test(0); Iter it = std::for_each_n(Iter(ia), s, std::ref(f)); assert(it == Iter(ia+s)); assert(f.count == s); for (unsigned i = 0; i < s; ++i) assert(ia[i] == static_cast<int>(i+1)); } { auto f = for_each_test(0); Iter it = std::for_each_n(Iter(ia), 1, std::ref(f)); assert(it == Iter(ia+1)); assert(f.count == 1); for (unsigned i = 0; i < 1; ++i) assert(ia[i] == static_cast<int>(i+2)); } #if TEST_STD_VER > 17 static_assert(test_constexpr()); #endif return 0; }
int main() { for_each_test(); accumulate_test(); boost::report_errors(); }
int main() { for_each_test(); boost::report_errors(); }