So I have a variable v
which may take several types, including (at least) Vector{T}
, SVector{N,T}
, where N
is an integer and T
is a real type (including at least Int
, Rational{Int}
and Float64
). I want to compute a type similar to v
but with element type promoted to some other type Q
.
In the case of SVector
, the following works: similar_type(v, Q)
. However, no method is implemented when v
is a plain old Vector
.
I could override this by defining StaticArrays.similar_type(::Vector, T::Type) = Vector{T}
(or, even better, a more general method, although this one does what I want), but this although this feels like fixing something which should have been done, it is still technically type-piracy. Since this is too trivial to reasonably have been an oversight in StaticArrays.jl
: is there a good reason why this package does not define similar_type
methods for plain Array
types?