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 // UNSUPPORTED: c++98, c++03 11 12 // <algorithm> 13 14 // template<class T, class Compare> 15 // T 16 // max(initializer_list<T> t, Compare comp); 17 18 #include <algorithm> 19 #include <functional> 20 #include <cassert> 21 22 #include "test_macros.h" 23 24 int main() 25 { 26 int i = std::max({2, 3, 1}, std::greater<int>()); 27 assert(i == 1); 28 i = std::max({2, 1, 3}, std::greater<int>()); 29 assert(i == 1); 30 i = std::max({3, 1, 2}, std::greater<int>()); 31 assert(i == 1); 32 i = std::max({3, 2, 1}, std::greater<int>()); 33 assert(i == 1); 34 i = std::max({1, 2, 3}, std::greater<int>()); 35 assert(i == 1); 36 i = std::max({1, 3, 2}, std::greater<int>()); 37 assert(i == 1); 38 #if TEST_STD_VER >= 14 39 { 40 static_assert(std::max({1, 3, 2}, std::greater<int>()) == 1, ""); 41 static_assert(std::max({2, 1, 3}, std::greater<int>()) == 1, ""); 42 static_assert(std::max({3, 2, 1}, std::greater<int>()) == 1, ""); 43 } 44 #endif 45 } 46