Shortcut for std::to_string?
Hello,
Unfortunately, I think I messed something up and my original post didn't go through.
I was wondering if there is a way to create a shortcut for std::to_string similar to what ReSharper does with highlighted text and entering brackets where it inserts at the beginning and end of the highlight.
Simple Example:
int x = 10;
int y = 15;
int components = 12;
int index = 0;
PrintFunction(const std::string& msg){....}
PrintFunction( index + " " + x + " " + y + " " + components);
Highlighting index and bringing up context menu and automatically changing index to std::to_string(index) etc.
I hope that makes sense, I thought ReSharper did this, but I can't find anything on it. Perhaps it can be done within ReSharper options using some of those more complicated functionality ReSharper provides? Custom?
Thanks!
Please sign in to leave a comment.
I guess ReSharper doesn't have a way to solve this. Thanks, anyways.
For those interested, I was able to create something in ReSharpers Template Explorer. I just used
std::to_string($SELECTION$)
for the code.
I'm trying to figure out how I can use it now without needing to go through 3 menus to select it.
Hi Ledloaf,
I've created a feature request for the corresponding context action: https://youtrack.jetbrains.com/issue/RSCPP-34729.
You can upvote the ticket to get a notification when it's implemented. Thanks!
There is a special `to_string` item in ReSharper postfix completion (https://www.jetbrains.com/help/resharper/Coding_Assistance_in_CPP.html#postfix_completion).
Press '.' after expression of integer type ('index' for instance):
and after completion of item 'to_string' code will be the following: