c++visual-studio-2015resharper-2016visual-assist-x

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)


Solution

  • 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