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 //   max(initializer_list<T> t, Compare comp);
15 
16 #include <algorithm>
17 #include <functional>
18 #include <cassert>
19 
main()20 int main()
21 {
22 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
23     int i = std::max({2, 3, 1}, std::greater<int>());
24     assert(i == 1);
25     i = std::max({2, 1, 3}, std::greater<int>());
26     assert(i == 1);
27     i = std::max({3, 1, 2}, std::greater<int>());
28     assert(i == 1);
29     i = std::max({3, 2, 1}, std::greater<int>());
30     assert(i == 1);
31     i = std::max({1, 2, 3}, std::greater<int>());
32     assert(i == 1);
33     i = std::max({1, 3, 2}, std::greater<int>());
34     assert(i == 1);
35 #if _LIBCPP_STD_VER > 11
36     {
37     static_assert(std::max({1, 3, 2}, std::greater<int>()) == 1, "");
38     static_assert(std::max({2, 1, 3}, std::greater<int>()) == 1, "");
39     static_assert(std::max({3, 2, 1}, std::greater<int>()) == 1, "");
40     }
41 #endif
42 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
43 }
44