Skip to content

Commit

Permalink
Merge daeaa83 into 5b4e390
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran authored Aug 23, 2022
2 parents 5b4e390 + daeaa83 commit 0b0efe2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "StaticArraysCore"
uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
version = "1.2.0"
version = "1.3.0"

[compat]
julia = "1.6"
Expand Down
22 changes: 22 additions & 0 deletions src/StaticArraysCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,26 @@ abstract type FieldVector{N, T} <: FieldArray{Tuple{N}, T, 1} end
struct StaticArrayStyle{N} <: Base.Broadcast.AbstractArrayStyle{N} end
StaticArrayStyle{M}(::Val{N}) where {M,N} = StaticArrayStyle{N}()

"""
similar_type(static_array)
similar_type(static_array, T)
similar_type(array, ::Size)
similar_type(array, T, ::Size)
Returns a constructor for a statically-sized array similar to the input array
(or type) `static_array`/`array`, optionally with different element type `T` or size
`Size`. If the input `array` is not a `StaticArray` then the `Size` is mandatory.
This differs from `similar()` in that the resulting array type may not be
mutable (or define `setindex!()`), and therefore the returned type may need to
be *constructed* with its data.
Note that the (optional) size *must* be specified as a static `Size` object (so the compiler
can infer the result statically).
New types should define the signature `similar_type(::Type{A},::Type{T},::Size{S}) where {A<:MyType,T,S}`
if they wish to overload the default behavior.
"""
function similar_type end

end # module

0 comments on commit 0b0efe2

Please sign in to comment.