You have kind of 3 types here, not 2: globalVar<double>, double and int
As far as I understand, you want to extract the template parameter double from globalVar<double>, before it is resolved.
But you also want to get it from wherever it is used with auto:
In this case, you want to get double from var.