sample.fail.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // UNSUPPORTED: c++98, c++03, c++11, c++14
  10. // <algorithm>
  11. // template <class PopulationIterator, class SampleIterator, class Distance,
  12. // class UniformRandomNumberGenerator>
  13. // SampleIterator sample(PopulationIterator first, PopulationIterator last,
  14. // SampleIterator out, Distance n,
  15. // UniformRandomNumberGenerator &&g);
  16. #include <algorithm>
  17. #include <random>
  18. #include <cassert>
  19. #include "test_iterators.h"
  20. template <class PopulationIterator, class SampleIterator> void test() {
  21. int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  22. const unsigned is = sizeof(ia) / sizeof(ia[0]);
  23. const unsigned os = 4;
  24. int oa[os];
  25. std::minstd_rand g;
  26. std::sample(PopulationIterator(ia), PopulationIterator(ia + is),
  27. SampleIterator(oa), os, g);
  28. }
  29. int main() {
  30. // expected-error@algorithm:* {{static_assert failed "SampleIterator must meet the requirements of RandomAccessIterator"}}
  31. // expected-error@algorithm:* 2 {{does not provide a subscript operator}}
  32. // expected-error@algorithm:* {{invalid operands}}
  33. test<input_iterator<int *>, output_iterator<int *> >();
  34. }