-
Notifications
You must be signed in to change notification settings - Fork 15
Description
@roystgnr we have this in compare_types:
// We can define CompareTypes template specializations with user types
// asymmetrically, to assist in disambiguation of templated functions
// or classes. But sometimes we just need the supertype:
// FIXME: this won't work yet for cases where CompareTypes depends on
// reverseorderI am curious what that comment really means? I am interested in going backwards and removing some of the decltypes in the return types of my NDDualNumber operations because they can result in value/derivative members with const and & specifiers which can mess-up down-stream type deductions. (A work-around is to apply std::remove_const and std::remove_reference, but I have started worrying about disambiguation of wrapper types as you discuss in libMesh/libmesh#1818)
If I go back to using return types based on CompareTypes, I run into the following problem when multiplying a NotADuckDualNumber tensor times a NotADuckDualNumber vector: the compiler considers this operator overload:
template <typename T, typename T2, typename D>
inline typename functorname##Type<NDDualNumber<T2, D>, T, true>::supertype operator opname(
const T & a, const NDDualNumber<T2, D> & b)
{
auto value = a opname b.value();
auto derivatives = dn_second_calc;
return {value, derivatives};
} and it instantiates this MultipliesType with T2 corresponding to the vector and T corresponding to the NDDualNumber tensor. Because of the switch in order, this goes down the line all the way to attempting to instantiate a MultipliesType<VectorValue, TensorValue> which I haven't defined because it doesn't make mathematical sense (unless we transposed the vector). Thoughts on how we can avoid this compilation error? Hopefully my explanation made sense.