|
23 | 23 | exprs = [:(ifelse($i < index, vec[$i], ifelse($i == index, x, vec[$i-1]))) for i = 1:length(vec) + 1]
|
24 | 24 | return quote
|
25 | 25 | $(Expr(:meta, :inline))
|
26 |
| - @boundscheck if (index < 1 || index > $(length(a)+1)) |
27 |
| - throw(BoundsError(a, index)) |
| 26 | + @boundscheck if (index < 1 || index > $(length(vec)+1)) |
| 27 | + throw(BoundsError(vec, index)) |
28 | 28 | end
|
29 | 29 | @inbounds return $(Expr(:call, newtype, Expr(:tuple, exprs...)))
|
30 | 30 | end
|
|
53 | 53 | exprs = [:(ifelse($i < index, vec[$i], vec[$i+1])) for i = 1:length(vec) + 1]
|
54 | 54 | return quote
|
55 | 55 | $(Expr(:meta, :inline))
|
56 |
| - @boundscheck if (index < 1 || index > $(length(a)+1)) |
57 |
| - throw(BoundsError(a, index)) |
| 56 | + @boundscheck if (index < 1 || index > $(length(vec)+1)) |
| 57 | + throw(BoundsError(vec, index)) |
58 | 58 | end
|
59 | 59 | @inbounds return $(Expr(:call, newtype, Expr(:tuple, exprs...)))
|
60 | 60 | end
|
61 | 61 | end
|
62 | 62 |
|
63 | 63 | # TODO consider prepend, append (can use vcat, but eltype might change), and
|
64 |
| -# maybe splice (a bit hard to get statically sized) |
| 64 | +# maybe splice (a bit hard to get statically sized without a "static" range) |
65 | 65 |
|
66 | 66 |
|
67 | 67 | # Immutable version of setindex!(). Seems similar in nature to the above, but
|
68 |
| -# could also live in src/indexing.jl |
| 68 | +# could also be justified to live in src/indexing.jl |
69 | 69 | @generated function setindex{T}(a::StaticArray{T}, x::T, index::Int)
|
70 | 70 | newtype = a
|
71 | 71 | exprs = [:(ifelse($i == index, x, a[$i])) for i = 1:length(a)]
|
|
0 commit comments