blob: e15a107cafad9ba35a6f4e7356bfda6e0eec5d3e [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <algorithm>
11
Howard Hinnanteb564e72010-08-22 00:08:10 +000012// template<class T, class Compare>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000013// T
14// max(initializer_list<T> t, Compare comp);
15
16#include <algorithm>
Howard Hinnant98e5d972010-08-21 20:10:01 +000017#include <functional>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000018#include <cassert>
19
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000020int main()
21{
Howard Hinnant73d21a42010-09-04 23:28:19 +000022#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant98e5d972010-08-21 20:10:01 +000023 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);
Howard Hinnant73d21a42010-09-04 23:28:19 +000035#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000036}