File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ Use `Static(N)` instead of `Val(N)` when you want it to behave like a number.
6
6
struct Static{N} <: Integer
7
7
Static {N} () where {N} = new {N::Int} ()
8
8
end
9
+
10
+ const Zero = Static {0} ()
11
+ const One = Static {1} ()
12
+
9
13
Base. @pure Static (N:: Int ) = Static {N} ()
10
14
Static (N:: Integer ) = Static (convert (Int, N))
11
15
Static (:: Static{N} ) where {N} = Static {N} ()
@@ -38,8 +42,8 @@ Base.iszero(::Static{0}) = true
38
42
Base. iszero (:: Static ) = false
39
43
Base. isone (:: Static{1} ) = true
40
44
Base. isone (:: Static ) = false
41
- Base. zero (:: Type{T} ) where {T<: Static } = Static {0} ()
42
- Base. one (:: Type{T} ) where {T<: Static } = Static {1} ()
45
+ Base. zero (:: Type{T} ) where {T<: Static } = Zero
46
+ Base. one (:: Type{T} ) where {T<: Static } = One
43
47
44
48
for T = [:Real , :Rational , :Integer ]
45
49
@eval begin
You can’t perform that action at this time.
0 commit comments