Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / algorithms / alg.modifying.operations / alg.random.sample / sample.verify.cpp
blobf979d72933d5e714322d3d90458b85e28652f882
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 // <algorithm>
13 // template <class PopulationIterator, class SampleIterator, class Distance,
14 // class UniformRandomNumberGenerator>
15 // SampleIterator sample(PopulationIterator first, PopulationIterator last,
16 // SampleIterator out, Distance n,
17 // UniformRandomNumberGenerator &&g);
19 #include <algorithm>
20 #include <random>
21 #include <cassert>
23 #include "test_iterators.h"
25 template <class PopulationIterator, class SampleIterator> void test() {
26 int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
27 const unsigned is = sizeof(ia) / sizeof(ia[0]);
28 const unsigned os = 4;
29 int oa[os];
30 std::minstd_rand g;
31 std::sample(PopulationIterator(ia), PopulationIterator(ia + is),
32 SampleIterator(oa), os, g);
35 int main(int, char**) {
36 // expected-error-re@*:* {{static assertion failed{{( due to requirement '.*')?}}{{.*}}SampleIterator must meet the requirements of RandomAccessIterator}}
37 // expected-error@*:* 2 {{does not provide a subscript operator}}
38 // expected-error@*:* {{invalid operands}}
39 test<cpp17_input_iterator<int *>, cpp17_output_iterator<int *> >();
41 return 0;