min_comp.pass.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <algorithm>
  10. // template<class T, StrictWeakOrder<auto, T> Compare>
  11. // requires !SameType<T, Compare> && CopyConstructible<Compare>
  12. // const T&
  13. // min(const T& a, const T& b, Compare comp);
  14. #include <algorithm>
  15. #include <functional>
  16. #include <cassert>
  17. template <class T, class C>
  18. void
  19. test(const T& a, const T& b, C c, const T& x)
  20. {
  21. assert(&std::min(a, b, c) == &x);
  22. }
  23. int main()
  24. {
  25. {
  26. int x = 0;
  27. int y = 0;
  28. test(x, y, std::greater<int>(), x);
  29. test(y, x, std::greater<int>(), y);
  30. }
  31. {
  32. int x = 0;
  33. int y = 1;
  34. test(x, y, std::greater<int>(), y);
  35. test(y, x, std::greater<int>(), y);
  36. }
  37. {
  38. int x = 1;
  39. int y = 0;
  40. test(x, y, std::greater<int>(), x);
  41. test(y, x, std::greater<int>(), x);
  42. }
  43. }