From 97035cfc9cd0ff18c016fc12c1ec39814f924f32 Mon Sep 17 00:00:00 2001 From: "C.Brenhin Keller" Date: Fri, 4 Feb 2022 16:01:52 -0500 Subject: [PATCH] Add new inner constructor for when you already have an NTuple of data --- src/ManualMemory.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ManualMemory.jl b/src/ManualMemory.jl index 9b68dd0..5ecc335 100644 --- a/src/ManualMemory.jl +++ b/src/ManualMemory.jl @@ -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))