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, so we check to make
26 // sure that our protection is working here.
27 // In some cases midpoint<int>(0,0) might get deduced as the pointer overload.
28
29 template <typename T>
test()30 void test()
31 {
32 ASSERT_SAME_TYPE(T, decltype(std::midpoint<T>(0, 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