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
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);
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;
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 *> >();