Upstream version 8.36.169.0
[platform/framework/web/crosswalk.git] / src / third_party / libc++ / trunk / test / algorithms / alg.sorting / alg.min.max / min.pass.cpp
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 //   min(const T& a, const T& b);
15
16 #include <algorithm>
17 #include <cassert>
18
19 template <class T>
20 void
21 test(const T& a, const T& b, const T& x)
22 {
23     assert(&std::min(a, b) == &x);
24 }
25
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, x);
38     test(y, x, x);
39     }
40     {
41     int x = 1;
42     int y = 0;
43     test(x, y, y);
44     test(y, x, y);
45     }
46 #if _LIBCPP_STD_VER > 11
47     {
48     constexpr int x = 1;
49     constexpr int y = 0;
50     static_assert(std::min(x, y) == y, "" );
51     static_assert(std::min(y, x) == y, "" );
52     }
53 #endif
54 }