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  // UNSUPPORTED: c++03, c++11, c++14, c++17
10  // <numeric>
11  
12  // template <class _Tp>
13  // _Tp midpoint(_Tp __a, _Tp __b) noexcept
14  //
15  
16  #include <cassert>
17  #include <cstddef>
18  #include <cstdint>
19  #include <numeric>
20  
21  #include "test_macros.h"
22  
23  //  Users are not supposed to provide template argument lists for
24  //  functions in the standard library (there's an exception for min and max)
25  //  However, libc++ protects against this for pointers. The use of T(0)
26  //  in the test cases resolves potential ambiguity in template argument deduction
27  //  for the std::midpoint function.
28  
29  template <typename T>
test()30  void test()
31  {
32    ASSERT_SAME_TYPE(T, decltype(std::midpoint<T>(T(0), T(0))));
33  }
34  
main(int,char **)35  int main(int, char**)
36  {
37      test<signed char>();
38      test<short>();
39      test<int>();
40      test<long>();
41      test<long long>();
42  
43      test<std::int8_t>();
44      test<std::int16_t>();
45      test<std::int32_t>();
46      test<std::int64_t>();
47  
48      test<unsigned char>();
49      test<unsigned short>();
50      test<unsigned int>();
51      test<unsigned long>();
52      test<unsigned long long>();
53  
54      test<std::uint8_t>();
55      test<std::uint16_t>();
56      test<std::uint32_t>();
57      test<std::uint64_t>();
58  
59  #ifndef TEST_HAS_NO_INT128
60      test<__int128_t>();
61      test<__uint128_t>();
62  #endif
63  
64      test<char>();
65      test<std::ptrdiff_t>();
66      test<std::size_t>();
67  
68      return 0;
69  }
70