简体   繁体   中英

Output the full type of a possibly failing typedef in Visual Studio 2019

I'm trying to output the full type of a typedef in the build log of Visual Studio; even for possibly failing typedefs, fe when a partial specialisation is missing. My specific version is 2019 but i also tried and failed with 2010 and 2015.

The only possible solution for this i could find is here but it doesn't work in Visual Studio.

Here's the testcode:

template<typename T>
struct Printer;
template <typename T>
struct ST;
template <>
struct ST<int&> {
    typedef int T;
};
template <typename T>
struct S {
    Printer<typename ST<T>::T> t;
};
int main() {
    typedef int& intref;
    S<intref> testi;

    typedef float& floatref;
    S<floatref> testf;

    typedef short& shortref;
    Printer<shortref> testsi;
}

And here is a godbolt

For this example, i'd like to see somewhere an output of

  1. " int " for the existing specialization
  2. " float& " for the missing specialization
  3. " short& " or " short int& " for the simple case

If I am placing the mouse cursor over the test incomplete object I can see the type passed as template argument see picture, it is not very clean but it is the only way I have found up to now.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM