//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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 "../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() { test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); }