//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: libcpp-has-no-incomplete-pstl // // template // void for_each(ExecutionPolicy&& exec, // ForwardIterator first, ForwardIterator last, // Function f); #include #include #include #include #include "test_macros.h" #include "test_execution_policies.h" #include "test_iterators.h" EXECUTION_POLICY_SFINAE_TEST(for_each); static_assert(sfinae_test_for_each); static_assert(!sfinae_test_for_each); template struct Test { template void operator()(Policy&& policy) { int sizes[] = {0, 1, 2, 100}; for (auto size : sizes) { std::vector a(size); std::vector called(size); std::for_each(policy, Iter(std::data(a)), Iter(std::data(a) + std::size(a)), [&](int& v) { assert(!called[&v - a.data()]); called[&v - a.data()] = true; }); assert(std::all_of(std::begin(called), std::end(called), [](bool b) { return b; })); } } }; int main(int, char**) { types::for_each(types::forward_iterator_list{}, TestIteratorWithPolicies{}); return 0; }