[X86] Use NSW/NUW flags on ISD::TRUNCATE nodes to improve X86 PACKSS/PACKUS lowering...
[llvm-project.git] / libcxx / test / std / algorithms / alg.sorting / alg.min.max / max.pass.cpp
blobf52c72b14ceae0914764de5561a6cdb8511e0351
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <algorithm>
11 // template<LessThanComparable T>
12 // const T&
13 // max(const T& a, const T& b);
15 #include <algorithm>
16 #include <cassert>
18 #include "test_macros.h"
20 template <class T>
21 void
22 test(const T& a, const T& b, const T& x)
24 assert(&std::max(a, b) == &x);
27 int main(int, char**)
30 int x = 0;
31 int y = 0;
32 test(x, y, x);
33 test(y, x, y);
36 int x = 0;
37 int y = 1;
38 test(x, y, y);
39 test(y, x, y);
42 int x = 1;
43 int y = 0;
44 test(x, y, x);
45 test(y, x, x);
47 #if TEST_STD_VER >= 14
49 constexpr int x = 1;
50 constexpr int y = 0;
51 static_assert(std::max(x, y) == x, "" );
52 static_assert(std::max(y, x) == x, "" );
54 #endif
56 return 0;