//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // template // complex::type> // pow(const T& x, const complex& y); // template // complex::type> // pow(const complex& x, const U& y); // template // complex::type> // pow(const complex& x, const complex& y); #include #include #include #include "test_macros.h" #include "../cases.h" template double promote(T, typename std::enable_if::value>::type* = 0); float promote(float); double promote(double); long double promote(long double); template void test(T x, const std::complex& y) { typedef decltype(promote(x)+promote(real(y))) V; static_assert((std::is_same >::value), ""); assert(std::pow(x, y) == pow(std::complex(x, 0), std::complex(y))); } template void test(const std::complex& x, U y) { typedef decltype(promote(real(x))+promote(y)) V; static_assert((std::is_same >::value), ""); assert(std::pow(x, y) == pow(std::complex(x), std::complex(y, 0))); } template void test(const std::complex& x, const std::complex& y) { typedef decltype(promote(real(x))+promote(real(y))) V; static_assert((std::is_same >::value), ""); assert(std::pow(x, y) == pow(std::complex(x), std::complex(y))); } template void test(typename std::enable_if::value>::type* = 0, typename std::enable_if::value>::type* = 0) { test(T(3), std::complex(4, 5)); test(std::complex(3, 4), T(5)); } template void test(typename std::enable_if::value>::type* = 0, typename std::enable_if::value>::type* = 0) { test(T(3), std::complex(4, 5)); test(std::complex(3, 4), U(5)); test(std::complex(3, 4), std::complex(5, 6)); } int main(int, char**) { test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); return 0; }