1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template<Arithmetic T>
16 #include <type_traits>
19 #include "test_macros.h"
22 template <class T
, int x
>
24 test(typename
std::enable_if
<std::is_integral
<T
>::value
>::type
* = 0)
26 static_assert((std::is_same
<decltype(std::imag(T(x
))), double>::value
), "");
27 assert(std::imag(x
) == 0);
30 static_assert(std::imag(val
) == 0, "");
31 constexpr std::complex<T
> t
{val
, val
};
32 static_assert(t
.imag() == x
, "" );
36 template <class T
, int x
>
38 test(typename
std::enable_if
<!std::is_integral
<T
>::value
>::type
* = 0)
40 static_assert((std::is_same
<decltype(std::imag(T(x
))), T
>::value
), "");
41 assert(std::imag(x
) == 0);
44 static_assert(std::imag(val
) == 0, "");
45 constexpr std::complex<T
> t
{val
, val
};
46 static_assert(t
.imag() == x
, "" );