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 // XFAIL: LIBCXX-AIX-FIXME 10 11 // <complex> 12 13 // template<Arithmetic T> 14 // T 15 // arg(T x); 16 17 #include <complex> 18 #include <type_traits> 19 #include <cassert> 20 21 #include "test_macros.h" 22 #include "../cases.h" 23 24 template <class T> 25 void 26 test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0) 27 { 28 static_assert((std::is_same<decltype(std::arg(x)), double>::value), ""); 29 assert(std::arg(x) == arg(std::complex<double>(static_cast<double>(x), 0))); 30 } 31 32 template <class T> 33 void 34 test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0) 35 { 36 static_assert((std::is_same<decltype(std::arg(x)), T>::value), ""); 37 assert(std::arg(x) == arg(std::complex<T>(x, 0))); 38 } 39 40 template <class T> 41 void 42 test() 43 { 44 test<T>(0); 45 test<T>(1); 46 test<T>(10); 47 } 48 49 int main(int, char**) 50 { 51 test<float>(); 52 test<double>(); 53 test<long double>(); 54 test<int>(); 55 test<unsigned>(); 56 test<long long>(); 57 58 return 0; 59 } 60