I have a base class that defines a constrained templated conversion operator
struct base {
template
To achieve a similar effect, you could move the constraints inside the operator and call the base conversion operator if the constraints are not satisfied:
struct base {
template , int> = 0>
operator C() const;
};
struct derived : base {
template
operator P() const {
if constexpr (different_constraints) {
// Overridden operator
} else {
return base::operator P();
}
}
};
Or equivalently have one regular std::enable_if_t conversion operator and another std::enable_if_t, int> = 0 that calls the base conversion operator.