Upstream version 8.36.169.0
[platform/framework/web/crosswalk.git] / src / third_party / libc++ / trunk / test / algorithms / alg.sorting / alg.min.max / min_init_list_comp.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<class T, class Compare>
13 //   T
14 //   min(initializer_list<T> t, Compare comp);
15
16 #include <algorithm>
17 #include <functional>
18 #include <cassert>
19
20 int main()
21 {
22 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
23     int i = std::min({2, 3, 1}, std::greater<int>());
24     assert(i == 3);
25     i = std::min({2, 1, 3}, std::greater<int>());
26     assert(i == 3);
27     i = std::min({3, 1, 2}, std::greater<int>());
28     assert(i == 3);
29     i = std::min({3, 2, 1}, std::greater<int>());
30     assert(i == 3);
31     i = std::min({1, 2, 3}, std::greater<int>());
32     assert(i == 3);
33     i = std::min({1, 3, 2}, std::greater<int>());
34     assert(i == 3);
35 #if _LIBCPP_STD_VER > 11
36     {
37     static_assert(std::min({1, 3, 2}, std::greater<int>()) == 3, "");
38     static_assert(std::min({2, 1, 3}, std::greater<int>()) == 3, "");
39     static_assert(std::min({3, 2, 1}, std::greater<int>()) == 3, "");
40     }
41 #endif
42 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
43 }