Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ enumerate_static(a::StaticArray) = StaticEnumerate(a)
end
end

if VERSION >= v"1.12.0-beta3"
@inline function map!(f, dest::StaticArray)
_map!(f, dest, Size(dest), dest)
end
end

@inline function map!(f, dest::StaticArray, a::StaticArray...)
_map!(f, dest, same_size(dest, a...), a...)
end
Expand Down
8 changes: 8 additions & 0 deletions test/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ using Statistics: mean
map!(+, mv3, v1, v2, v3)
@test mv3 == @MVector [7, 9, 11, 13]

if VERSION >= v"1.12.0-beta3"
@testset "map!(function, array)" begin
local mv = MVector(1,2,3)
map!(x->x^2, mv)
@test mv == SA[1,4,9]
end
end

# Output eltype for empty cases #528
@test @inferred(map(/, SVector{0,Int}(), SVector{0,Int}())) === SVector{0,Float64}()
@test @inferred(map(+, SVector{0,Int}(), SVector{0,Float32}())) === SVector{0,Float32}()
Expand Down
Loading