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 // <complex> 10 11 // template<Arithmetic T> 12 // T 13 // arg(T x); 14 15 #include <complex> 16 #include <type_traits> 17 #include <cassert> 18 19 #include "test_macros.h" 20 #include "../cases.h" 21 22 template <class T> 23 void 24 test(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>(static_cast<double>(x), 0))); 28 } 29 30 template <class T> 31 void 32 test(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 38 template <class T> 39 void 40 test() 41 { 42 test<T>(0); 43 test<T>(1); 44 test<T>(10); 45 } 46 47 int main(int, char**) 48 { 49 test<float>(); 50 test<double>(); 51 test<long double>(); 52 test<int>(); 53 test<unsigned>(); 54 test<long long>(); 55 56 return 0; 57 } 58