Best practices to add more than one bound to type parameters

Taking a step back, it seems like there’s another way to accomplish your goal, by using UnionAll to add a second supertype constraint:

struct myTImpl{T, N, V<:NTuple{N, T}}
    a::V
end

const TwoOrThreeTuple{T} = Union{NTuple{2, T}, NTuple{3, T}}

const myT = myTImpl{T, N, V} where {T, N, V<:TwoOrThreeTuple{T}}

function myT(a::V) where {T, N, V<:NTuple{N, T}}
    myT{T, N, V}(a)
end

NB: given that you’re interested in defining types with redundancy among their type parameters, you might benefit from my package TypeCompletion.jl.

1 Like