[LLD][COFF] Emit locally imported EC symbols for ARM64X (#125527)
[llvm-project.git] / libcxx / test / std / numerics / numeric.ops / reduce / pstl.reduce.pass.cpp
blobf5748d7c823b7a47b279aa836007e0842ded7278
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
11 // UNSUPPORTED: libcpp-has-no-incomplete-pstl
13 // <numeric>
15 // template<class ExecutionPolicy, class ForwardIterator>
16 // typename iterator_traits<ForwardIterator>::value_type
17 // reduce(ExecutionPolicy&& exec,
18 // ForwardIterator first, ForwardIterator last);
19 // template<class ExecutionPolicy, class ForwardIterator, class T, class BinaryOperation>
20 // T reduce(ExecutionPolicy&& exec,
21 // ForwardIterator first, ForwardIterator last, T init,
22 // BinaryOperation binary_op);
24 #include <numeric>
25 #include <vector>
27 #include "MoveOnly.h"
28 #include "test_execution_policies.h"
29 #include "test_iterators.h"
30 #include "test_macros.h"
32 template <class Iter, class ValueT>
33 struct Test {
34 template <class Policy>
35 void operator()(Policy&& policy) {
36 for (const auto& pair : {std::pair{0, 34}, {1, 36}, {2, 39}, {100, 5184}, {350, 61809}}) {
37 auto [size, expected] = pair;
38 std::vector<int> a(size);
39 for (int i = 0; i != size; ++i)
40 a[i] = i;
43 decltype(auto) ret = std::reduce(
44 policy, Iter(std::data(a)), Iter(std::data(a) + std::size(a)), ValueT(34), [](ValueT i, ValueT j) {
45 return i + j + 2;
46 });
47 static_assert(std::is_same_v<decltype(ret), ValueT>);
48 assert(ret == ValueT(expected));
51 decltype(auto) ret = std::reduce(policy, Iter(std::data(a)), Iter(std::data(a) + std::size(a)), ValueT(34));
52 static_assert(std::is_same_v<decltype(ret), ValueT>);
53 assert(ret == expected - 2 * size);
56 decltype(auto) ret = std::reduce(policy, Iter(std::data(a)), Iter(std::data(a) + std::size(a)));
57 static_assert(std::is_same_v<decltype(ret), typename std::iterator_traits<Iter>::value_type>);
58 assert(ret == expected - 2 * size - 34);
64 int main(int, char**) {
65 types::for_each(types::forward_iterator_list<int*>{}, types::apply_type_identity{[](auto v) {
66 using Iter = typename decltype(v)::type;
67 types::for_each(
68 types::type_list<int, MoveOnly>{},
69 TestIteratorWithPolicies<types::partial_instantiation<Test, Iter>::template apply>{});
70 }});
72 return 0;