I have some code using traits, where I want to dispatch on a specific type parameter of a function argument. Is there a shortcut for omitting the other parameters, if the one I want to dispatch on is not the first parameter?
For definiteness, consider an example of a type with three parameters:
struct mystruct{T1,T2,T3}
end
If I want to dispatch on the last parameter I have to write either something like
test(::mystruct{<:Any,<:Any,<:Nothing}) = true
test(::mystruct{<:Any,<:Any,<:Any}) = false
or
test(::mystruct{T1,T2,T3}) where {T1,T2,T3<:Nothing} = true
test(::mystruct{T1,T2,T3}) where {T1,T2,T3} = false
In the actual code there are more than just three type parameters, hence it would be convenient not having to spell out all parameters, e.g., something like
test(::mystruct{,,<:Nothing}) = true
test(::mystruct{,,<:Any}) = false