Skip to content

Commit 0039fab

Browse files
ChrisRackauckasjrevels
authored andcommitted
Add constructor <--> convert pun for TrackedReal (#112)
1 parent c6ae6dd commit 0039fab

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/tracked.jl

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ TrackedReal(v::V, a::D, tp::InstructionTape, i::Int, o::O) where {V,D,O} = Track
6060

6161
TrackedReal(v::V, a::D, tp::InstructionTape = NULL_TAPE) where {V,D} = TrackedReal{V,D,Nothing}(v, a, tp)
6262

63+
# we define these special cases so that the "constructor <--> convert" pun holds for `TrackedReal`
64+
# this is Jarett's favorite piece of code. A true work of art.
65+
@inline TrackedReal{V,D,O}(x::TrackedReal) where {V,D,O} = convert(TrackedReal{V,D,O}, x)
66+
6367
# TrackedArray #
6468
#--------------#
6569

0 commit comments

Comments
 (0)