brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · f979d72 Raw
43 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++1410 11// <algorithm>12 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);18 19#include <algorithm>20#include <random>21#include <cassert>22 23#include "test_iterators.h"24 25template <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);33}34 35int 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 *> >();40 41  return 0;42}43