//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template Compare> // requires !SameType && CopyConstructible // const T& // max(const T& a, const T& b, Compare comp); #include #include #include template void test(const T& a, const T& b, C c, const T& x) { assert(&std::max(a, b, c) == &x); } int main() { { int x = 0; int y = 0; test(x, y, std::greater(), x); test(y, x, std::greater(), y); } { int x = 0; int y = 1; test(x, y, std::greater(), x); test(y, x, std::greater(), x); } { int x = 1; int y = 0; test(x, y, std::greater(), y); test(y, x, std::greater(), y); } #if _LIBCPP_STD_VER > 11 { constexpr int x = 1; constexpr int y = 0; static_assert(std::max(x, y, std::greater()) == y, "" ); static_assert(std::max(y, x, std::greater()) == y, "" ); } #endif }