diff --git a/src/BitFlags.jl b/src/BitFlags.jl index 868e193..622b9e9 100644 --- a/src/BitFlags.jl +++ b/src/BitFlags.jl @@ -25,6 +25,8 @@ Base.isless(x::T, y::T) where {T<:BitFlag} = isless(basetype(T)(x), basetype(T)( Base.:|(x::T, y::T) where {T<:BitFlag} = T(Integer(x) | Integer(y)) Base.:&(x::T, y::T) where {T<:BitFlag} = T(Integer(x) & Integer(y)) +Base.broadcastable(x::BitFlag) = Ref(x) + function Base.print(io::IO, x::T) where T<:BitFlag compact = get(io, :compact, false)::Bool xi = Integer(x) diff --git a/test/runtests.jl b/test/runtests.jl index 5d99f16..aea7bae 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -66,6 +66,9 @@ end # Hashing @test Int(flag2a) == Int(flag3a) # same numerical value, but @test hash(flag2a) != hash(flag3a) # unique hashes as BitFlag + + # Broadcasting + @test [flag1a, flag1b] .| flag1c == [flag1a | flag1c, flag1b | flag1c] #end #@testset "Type properties" begin