template<typename T> int globalVar = 123;
^^^---- apparent type int
^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- effective type (int)<T> [ with T resovled at instantiation site]
(int)<T> : is not a correct C++, it is invented for the purpose of this talk.
So
auto var = globalVar<double>;
Apparent type of var is int.
But effective type is (int)<double>, in words it say, a variable template of type int instantiated with type double.
>>>Thank you Sébastien for the perfect short summary.
Oops, Sebastian, not Sébastien, sorry :)
-------- Original message --------
From: Sebastian Wittmeier via Std-Proposals <std-proposals@lists.isocpp.org>
Date: 7/30/24 6:05 PM (GMT+04:00)
To: std-proposals@lists.isocpp.org
Cc: Sebastian Wittmeier <wittmeier@projectalpha.org>
Subject: Re: [std-proposals] Function overload set type information loss
template<typename T>
int globalVar = 123;
This is a variable template;
globalVar<double> var;
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:
auto var = globalVar<double>;
In this case, you want to get double from var.