1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template<class T, StrictWeakOrder<auto, T> Compare>
13 // requires !SameType<T, Compare> && CopyConstructible<Compare>
14 // pair<const T&, const T&>
15 // minmax(const T& a, const T& b, Compare comp);
21 template <class T, class C>
23 test(const T& a, const T& b, C c, const T& x, const T& y)
25 std::pair<const T&, const T&> p = std::minmax(a, b, c);
26 assert(&p.first == &x);
27 assert(&p.second == &y);
36 test(x, y, std::greater<int>(), x, y);
37 test(y, x, std::greater<int>(), y, x);
42 test(x, y, std::greater<int>(), y, x);
43 test(y, x, std::greater<int>(), y, x);
48 test(x, y, std::greater<int>(), x, y);
49 test(y, x, std::greater<int>(), x, y);
51 #if _LIBCPP_STD_VER > 11
53 // Note that you can't take a reference to a local var, since
54 // its address is not a compile-time constant.
55 constexpr static int x = 1;
56 constexpr static int y = 0;
57 constexpr auto p1 = std::minmax(x, y, std::greater<>());
58 static_assert(p1.first == x, "");
59 static_assert(p1.second == y, "");
60 constexpr auto p2 = std::minmax(y, x, std::greater<>());
61 static_assert(p2.first == x, "");
62 static_assert(p2.second == y, "");