views:

66

answers:

2

Imagine you have a function, if you hover over it with the mouse in visual studio you'll get the function prototype. Is it possible to print to the screen the return type of this function ?

This is a practical question, not a programming one. Does the functionality exist in VS ?

A: 

Why would you want to do this? Is this function a template and you don't know its return type at runtime?

template <typename T>
T dostuff () 
{
    //does stuff
    cout << typeid(T).name();
    return T;
}
Ricardo Ferreira
I just don't want to type the return type of functions, it's quite tiring. If I have a function that returns std::map<std::wstring,bool>, I want to click a button and have the return type typed for me.
anno
Note that the type will never be `std::map<std::wstring,bool>`. `std::wstring` is a typedef for std::basic_string<wchar_t>`, and furthermore both `std::wstring` and `std::map` have defaulted template arguments.
MSalters
+2  A: 

I don't know a direct way, but here's a workaround that is relatively easy.

  1. Right click on the function name.
  2. Choose either "Go to definition" or "Go to declaration".
  3. Select/copy the return type using standard copy/paste features.
R Samuel Klatchko
I can type F12 also :) I guess what I'm looking for doesn't exist. Thanks for understanding the question.
anno