This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To ensure correct alignment (e.g. for an 80-bit type) | |
struct StrWrap{T} | |
value::T | |
end | |
function unsafe_reinterpret(T, a::A) where {A} | |
if sizeof(T) <= sizeof(A) | |
r = Ref(a) | |
Base.@gc_preserve r begin | |
u = convert(Ptr{T}, Base.unsafe_convert(Ptr{A}, r)) |