Skip to content

Commit 3f65897

Browse files
committed
restore original Base.similar behavior, specialize on StaticArrays
1 parent b9b35d9 commit 3f65897

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/vector_of_array.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,12 @@ end
701701

702702
function Base.similar(vec::VectorOfArray{
703703
T, N, AT}) where {T, N, AT <: AbstractArray{<:AbstractArray{T}}}
704+
return VectorOfArray(similar.(Base.parent(vec)))
705+
end
706+
707+
function Base.similar(vec::VectorOfArray{
708+
T, N, AT}) where {T, N, AT <: AbstractArray{<:StaticArraysCore.StaticVecOrMat{T}}}
709+
# this avoids behavior such as similar(SVector) returning an MVector
704710
return VectorOfArray(similar(Base.parent(vec)))
705711
end
706712

0 commit comments

Comments
 (0)