1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
10 // UNSUPPORTED: no-exceptions
11 // REQUIRES: has-unix-headers
13 // UNSUPPORTED: libcpp-has-no-incomplete-pstl
15 // check that std::transform(ExecutionPolicy) terminates on user-thrown exceptions
19 #include "check_assertion.h"
20 #include "test_execution_policies.h"
21 #include "test_iterators.h"
23 int main(int, char**) {
24 test_execution_policies([&](auto&& policy
) {
25 EXPECT_STD_TERMINATE([&] {
30 policy
, std::begin(a
), std::end(a
), std::begin(b
), std::begin(c
), [](auto v
, auto) -> decltype(v
) {
34 EXPECT_STD_TERMINATE([&] {
39 util::throw_on_move_iterator(std::begin(a
), 1),
40 util::throw_on_move_iterator(std::end(a
), 1),
41 util::throw_on_move_iterator(std::begin(a
), 1),
42 [](int i
) { return i
; });
43 } catch (const util::iterator_error
&) {
46 std::terminate(); // make the test pass in case the algorithm didn't move the iterator
49 EXPECT_STD_TERMINATE([&] {
52 (void)std::transform(policy
, std::begin(a
), std::end(a
), std::begin(b
), [](auto v
) -> decltype(v
) {
56 EXPECT_STD_TERMINATE([&] {
61 util::throw_on_move_iterator(std::begin(a
), 1),
62 util::throw_on_move_iterator(std::end(a
), 1),
63 util::throw_on_move_iterator(std::begin(a
), 1),
64 util::throw_on_move_iterator(std::begin(a
), 1),
66 } catch (const util::iterator_error
&) {
69 std::terminate(); // make the test pass in case the algorithm didn't move the iterator