Due to a very very long list of constraints and gotchas... in a special math library that uses libc++ (and in other cases, libstdc++), which I am trying to extend, I am attempting to fully specialize just the division operation because in libc++ it uses functions like scalbn
and logb
that are not available for the type in question, A
in this example. For libstdc++, it doesn't matter since those functions aren't called. Here is a minimal case that triggers the error message I'm running into; see it not work. It is not apparent to me from looking at the -E
output what other base template, probably with more parameters, is causing this message, though it also happens with libstdc++. Yes, I realize I should not be defining things in the standard namespace. Yes, I am aware of ADL being able to bring in namespaces as a way to prevent defining things in std, as well as other techniques. That is not what I want to do here. Thank you for any help you can give.
#include <complex>
#include <iostream>
template <class T> struct A{ T a; };
namespace std{
//template <> // if uncommented, warning: extraneous template parameter list in template specialization
template <class T>
inline std::complex<A<T>>
operator/ <A<T>> ( // either way, error: function template partial specialization is not allowed
std::complex<A<T>> const&,
std::complex<A<T>> const&) {
std::cerr<<"full explicit specialization called\n";
return std::complex<A<T>>();
}
}
int main(int,char*[]){
A<double> myA{10};
A<double> myOtherA{5};
std::complex<A<double>> r(std::complex(myA)/std::complex(myOtherA));
std::cerr<<r.real().a<<"\n";
return 0;
}