While using xt::allclose on two objects containing std::complex<float>, I got an error from xtl::promote_type<std::complex<float>, std::complex<float>, double> that it tried determining the type when adding a std::complex<float> to a std::complex<double>, which is not defined.
When evaluating xtl::promote_type<std::complex<float>, std::complex<float>, double>, xtl indeed first recursively evaluates xtl::promote_type<std::complex<float>, double>, which yields a std::complex<double>. Then it determines the type of adding std::complex<float> and std::complex<double> using decltype and declval, which fails.
This fix avoids the addition operator in recursive calls of the promote_type template by generalizing the existing recursive template that already uses a bool as a first argument.
I also added a test that fails to compile without the fix and works fine with the fix.
I see that my editor removed some spaces and a final newline. Please let me know if that's a problem.
While using
xt::allclose
on two objects containingstd::complex<float>
, I got an error fromxtl::promote_type<std::complex<float>, std::complex<float>, double>
that it tried determining the type when adding astd::complex<float>
to astd::complex<double>
, which is not defined.When evaluating
xtl::promote_type<std::complex<float>, std::complex<float>, double>
, xtl indeed first recursively evaluatesxtl::promote_type<std::complex<float>, double>
, which yields astd::complex<double>
. Then it determines the type of addingstd::complex<float>
andstd::complex<double>
usingdecltype
anddeclval
, which fails.This fix avoids the addition operator in recursive calls of the
promote_type
template by generalizing the existing recursive template that already uses abool
as a first argument.I also added a test that fails to compile without the fix and works fine with the fix.
I see that my editor removed some spaces and a final newline. Please let me know if that's a problem.