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 // UNSUPPORTED: c++03, c++11, c++14 10 11 // Test failure not investigated on GCC 5. 12 // UNSUPPORTED: gcc-5 13 14 // <algorithm> 15 16 // template <class PopulationIterator, class SampleIterator, class Distance, 17 // class UniformRandomNumberGenerator> 18 // SampleIterator sample(PopulationIterator first, PopulationIterator last, 19 // SampleIterator out, Distance n, 20 // UniformRandomNumberGenerator &&g); 21 22 #include <algorithm> 23 #include <random> 24 #include <cassert> 25 26 #include "test_iterators.h" 27 28 template <class PopulationIterator, class SampleIterator> void test() { 29 int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; 30 const unsigned is = sizeof(ia) / sizeof(ia[0]); 31 const unsigned os = 4; 32 int oa[os]; 33 std::minstd_rand g; 34 std::sample(PopulationIterator(ia), PopulationIterator(ia + is), 35 SampleIterator(oa), os, g); 36 } 37 38 int main(int, char**) { 39 // expected-error-re@algorithm:* {{static_assert failed{{( due to requirement '.*')?}} "SampleIterator must meet the requirements of RandomAccessIterator"}} 40 // expected-error@algorithm:* 2 {{does not provide a subscript operator}} 41 // expected-error@algorithm:* {{invalid operands}} 42 test<input_iterator<int *>, output_iterator<int *> >(); 43 44 return 0; 45 } 46