Skip to content

Commit 0b0efe2

Browse files
authored
Merge daeaa83 into 5b4e390
2 parents 5b4e390 + daeaa83 commit 0b0efe2

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "StaticArraysCore"
22
uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
3-
version = "1.2.0"
3+
version = "1.3.0"
44

55
[compat]
66
julia = "1.6"

src/StaticArraysCore.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,4 +389,26 @@ abstract type FieldVector{N, T} <: FieldArray{Tuple{N}, T, 1} end
389389
struct StaticArrayStyle{N} <: Base.Broadcast.AbstractArrayStyle{N} end
390390
StaticArrayStyle{M}(::Val{N}) where {M,N} = StaticArrayStyle{N}()
391391

392+
"""
393+
similar_type(static_array)
394+
similar_type(static_array, T)
395+
similar_type(array, ::Size)
396+
similar_type(array, T, ::Size)
397+
398+
Returns a constructor for a statically-sized array similar to the input array
399+
(or type) `static_array`/`array`, optionally with different element type `T` or size
400+
`Size`. If the input `array` is not a `StaticArray` then the `Size` is mandatory.
401+
402+
This differs from `similar()` in that the resulting array type may not be
403+
mutable (or define `setindex!()`), and therefore the returned type may need to
404+
be *constructed* with its data.
405+
406+
Note that the (optional) size *must* be specified as a static `Size` object (so the compiler
407+
can infer the result statically).
408+
409+
New types should define the signature `similar_type(::Type{A},::Type{T},::Size{S}) where {A<:MyType,T,S}`
410+
if they wish to overload the default behavior.
411+
"""
412+
function similar_type end
413+
392414
end # module

0 commit comments

Comments
 (0)