golosovsky
golosovsky

Reputation: 718

C++ ReSharper - generating a variable of function's return value / parameter type

Isn't there a ReSharper 2016 C++/VisualAssist X C++/VS 2015 shortcut for generating a variable of function's return value / specific parameter type?

(I'm not talking about auto, I mean the actual type)

Upvotes: 0

Views: 112

Answers (2)

Igor Akhmetov
Igor Akhmetov

Reputation: 1930

ReSharper C++ has "Introduce Variable" refactoring for that purpose. Similar to VAX, you can also use "Create local variable"/"Create global variable"/"Create field" quick fixes.

Upvotes: 1

Visual Assist support
Visual Assist support

Reputation: 121

If you already have a variable name in place, then you can use Visual Assist's "Create From Usage" command to do this. Using the very simple test case:

std::pair<int, long> getPairsOfNumbers();

void testingNewVariableForFunctionReturn()
{
    pairVar = getPairsOfNumbers();
}

Create From Usage on the unknown symbol "pairVar" gives you the option to create a new local variable of the correct type. Alt-Shift-Q is the default keyboard shortcut for the refactoring context menu, once you have placed the caret into the variable name.

Create From Usage documentation here: https://wholetomato.fogbugz.com/default.asp?W164

Upvotes: 2

Related Questions