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//===----------------------------------------------------------------------===//
8
9// Check that PSTL algorithms are marked [[nodiscard]] as a conforming extension
10
11// UNSUPPORTED: libcpp-has-no-incomplete-pstl
12
13// UNSUPPORTED: c++03, c++11, c++14
14
15// clang-format off
16
17#include <algorithm>
18#include <execution>
19#include <iterator>
20
21void test() {
22 int a[] = {1};
23 auto pred = [](auto) { return false; };
24 std::all_of(exec: std::execution::par, first: std::begin(arr&: a), last: std::end(arr&: a), pred: pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
25 std::any_of(exec: std::execution::par, first: std::begin(arr&: a), last: std::end(arr&: a), pred: pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
26 std::none_of(exec: std::execution::par, first: std::begin(arr&: a), last: std::end(arr&: a), pred: pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
27 std::is_partitioned(exec: std::execution::par, first: std::begin(arr&: a), last: std::end(arr&: a), pred: pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
28}
29

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of libcxx/test/libcxx/diagnostics/pstl.nodiscard.verify.cpp