Constructors for Primitive types

Try this:

primitive type Basis{V,G} <: Unsigned 16 end

Basis{V,G}(x::UInt16) where {V,G} = reinterpret(Basis{V,G}, x)

UInt16(x::Basis) = reinterpret(UInt16, x)

Base.show(io::IO, x::Basis) = print(io, UInt16(x))

Basis{4,3}(0x0007)
4 Likes