1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <complex>
11
12// template<Arithmetic T>
13//   T
14//   arg(T x);
15
16#include <complex>
17#include <type_traits>
18#include <cassert>
19
20#include "../cases.h"
21
22template <class T>
23void
24test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
25{
26    static_assert((std::is_same<decltype(std::arg(x)), double>::value), "");
27    assert(std::arg(x) == arg(std::complex<double>(x, 0)));
28}
29
30template <class T>
31void
32test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
33{
34    static_assert((std::is_same<decltype(std::arg(x)), T>::value), "");
35    assert(std::arg(x) == arg(std::complex<T>(x, 0)));
36}
37
38template <class T>
39void
40test()
41{
42    test<T>(0);
43    test<T>(1);
44    test<T>(10);
45}
46
47int main()
48{
49    test<float>();
50    test<double>();
51    test<long double>();
52    test<int>();
53    test<unsigned>();
54    test<long long>();
55}
56