Skip to content

Commit

Permalink
Specialize capture to work with StaticArrays
Browse files Browse the repository at this point in the history
  • Loading branch information
bzinberg committed Oct 14, 2020
1 parent fd62c7c commit 622e50f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/tracked.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ unseed!(x::AbstractArray, i) = unseed!(x[i])
capture(t::TrackedReal) = ifelse(hastape(t), t, value(t))
capture(t::TrackedArray) = t
capture(t::AbstractArray) = istracked(t) ? map!(capture, similar(t), t) : copy(t)
# `StaticArray`s don't support mutation unless the eltype is a bits type (`isbitstype`).
capture(t::SA) where SA <: StaticArray = istracked(t) ? SA(map(capture, t)) : copy(t)

########################
# Conversion/Promotion #
Expand Down

0 comments on commit 622e50f

Please sign in to comment.