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
10 // <algorithm>
11
12 // template<LessThanComparable T>
13 // const T&
14 // max(const T& a, const T& b);
15
16 #include <algorithm>
17 #include <cassert>
18
19 template <class T>
20 void
test(const T & a,const T & b,const T & x)21 test(const T& a, const T& b, const T& x)
22 {
23 assert(&std::max(a, b) == &x);
24 }
25
main()26 int main()
27 {
28 {
29 int x = 0;
30 int y = 0;
31 test(x, y, x);
32 test(y, x, y);
33 }
34 {
35 int x = 0;
36 int y = 1;
37 test(x, y, y);
38 test(y, x, y);
39 }
40 {
41 int x = 1;
42 int y = 0;
43 test(x, y, x);
44 test(y, x, x);
45 }
46 #if _LIBCPP_STD_VER > 11
47 {
48 constexpr int x = 1;
49 constexpr int y = 0;
50 static_assert(std::max(x, y) == x, "" );
51 static_assert(std::max(y, x) == x, "" );
52 }
53 #endif
54 }
55