Seems, that I was able to do it, but I don’t know if this approach is correct, not sure how many types will be crated based on SIZE.
mutable struct Context{TYPE_VAR_STACK <: Union{UInt8, UInt16}, N <:Union{UInt8, UInt16}, SIZE}
stack::SizedVector{SIZE, TYPE_VAR_STACK}
index::N
function Context(stack_type::Type{T}, stack_length::N, def_stack_val::T=eltype(stack_type)(0)) where {T <: Union{UInt8, UInt16}, N <: Union{UInt8, UInt16}}
# StaticArrays pkg doesn't allow to have its Size in different types than Int
size = Int64(stack_length)
stack = SizedVector{size, stack_type}(fill(def_stack_val, size))
return new{T, N, size}(stack, firstindex(stack))
end
end
julia> sdd = Context(UInt16, UInt16(1200), UInt16(33))
Context{UInt16, UInt16, 1200}(UInt16[0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021 … 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021], 0x0001)