Skip to content

Commit

Permalink
Add new inner constructor for when you already have an NTuple of data
Browse files Browse the repository at this point in the history
  • Loading branch information
brenhinkeller committed Feb 4, 2022
1 parent 71ef718 commit 97035cf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ManualMemory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ mutable struct MemoryBuffer{N,T}
@assert Base.allocatedinline(T)
new{N,T}()
end
@inline function MemoryBuffer(data::NTuple{N,T}) where {N,T}
@assert Base.allocatedinline(T)
new{N,T}(data)
end
end
@inline Base.unsafe_convert(::Type{Ptr{T}}, m::MemoryBuffer) where {T} = Ptr{T}(pointer_from_objref(m))
@inline Base.pointer(m::MemoryBuffer{N,T}) where {N,T} = Ptr{T}(pointer_from_objref(m))
Expand Down

0 comments on commit 97035cf

Please sign in to comment.