1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <algorithm>
10
11// template<LessThanComparable T>
12// const T&
13// min(const T& a, const T& b);
14
15#include <algorithm>
16#include <cassert>
17
18#include "test_macros.h"
19
20template <class T>
21void
22test(const T& a, const T& b, const T& x)
23{
24 assert(&std::min(a, b) == &x);
25}
26
27int main(int, char**)
28{
29 {
30 int x = 0;
31 int y = 0;
32 test(a: x, b: y, x);
33 test(y, x, y);
34 }
35 {
36 int x = 0;
37 int y = 1;
38 test(x, y, x);
39 test(y, x, x);
40 }
41 {
42 int x = 1;
43 int y = 0;
44 test(x, y, y);
45 test(y, x, y);
46 }
47#if TEST_STD_VER >= 14
48 {
49 constexpr int x = 1;
50 constexpr int y = 0;
51 static_assert(std::min(x, y) == y, "" );
52 static_assert(std::min(y, x) == y, "" );
53 }
54#endif
55
56 return 0;
57}
58

source code of libcxx/test/std/algorithms/alg.sorting/alg.min.max/min.pass.cpp