Skip to content

Commit

Permalink
default zero-initialize RefValues of numeric types
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Apr 24, 2017
1 parent 98a7d0c commit 1ae9b2d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base/refpointer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ unsafe_convert(::Type{Ref{T}}, x) where {T} = unsafe_convert(Ptr{T}, x)

mutable struct RefValue{T} <: Ref{T}
x::T
RefValue{T}() where {T} = new()
RefValue{T}(x) where {T} = new(x)
RefValue{T}() where {T} = new()
RefValue{T}() where {T<:Ptr} = new(C_NULL)
RefValue{T}() where {T<:Number} = isbits(T) ? new(zero(T)) : new()
end
RefValue{T}(x::T) = RefValue{T}(x)
isassigned(x::RefValue) = isdefined(x, :x)
Expand Down

0 comments on commit 1ae9b2d

Please sign in to comment.