diff --git a/src/FixedSizeArray.jl b/src/FixedSizeArray.jl index 0a621f7..c51c797 100644 --- a/src/FixedSizeArray.jl +++ b/src/FixedSizeArray.jl @@ -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)) @@ -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}))