Skip to content
Draft
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
16 changes: 15 additions & 1 deletion src/FixedSizeArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ end

# unsafe: the native address of the array's storage

Base.cconvert(::Type{<:Ptr}, a::FixedSizeArray) = parent(a)
function Base.cconvert(::Type{Ptr{T}}, a::FixedSizeArray{T}) where {T}
Base.cconvert(Ptr{T}, parent(a))
end

function Base.unsafe_convert(::Type{Ptr{T}}, a::FixedSizeArray{T}) where {T}
Base.unsafe_convert(Ptr{T}, parent(a))
Expand All @@ -393,6 +395,18 @@ end

Base.elsize(::Type{A}) where {A<:FixedSizeArray} = Base.elsize(parent_type(A))

@static if isdefined(Base, :try_strides)
@inline size_to_strides(s, d, sz...) = (s, size_to_strides(s * d, sz...)...)
size_to_strides(s, d) = (s,)
size_to_strides(s) = ()
function Base.try_strides(a::FixedSizeArray)
s = @something try_strides(parent(a)) return nothing
size_to_strides(only(s), size(a)...)
end
Base.is_ptr_loadable(a::FixedSizeArray) = is_ptr_loadable(parent(a))
Base.is_ptr_storable(a::FixedSizeArray) = is_ptr_storable(parent(a))
end

# `reshape`: specializing it to ensure it returns a `FixedSizeArray`

function Base.reshape(a::FixedSizeArray, size::(NTuple{N,Int} where {N}))
Expand Down
Loading