Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 const std::string& foo to const std::string &foo

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
Vertexwahn Posted - Jul 01 2015 : 05:26:17 AM
Would be nice if there would be an easy way to change function parameters from


const std::string& foo


to


const std::string &foo


For instance:

virtual void setValue(
	const BlueFramework::Core::String& name,
	const BlueFramework::Core::Math::vector2i& value) = 0;


to


virtual void setValue(
	const BlueFramework::Core::String &name,
	const BlueFramework::Core::Math::vector2i &value) = 0;


I have hundreds of lines of code where the reference & is bound to the type and not to the name - Would be very nice this refactoring can be done automatically

The following options would be nice:

  • Bind reference symbol (&) to variable name

  • Bind reference symbol (&) to variable type

  • Bind pointer symbol (*) to variable name

  • Bind pointer symbol (*) to variable type


3   L A T E S T    R E P L I E S    (Newest First)
Dusan Posted - Jul 08 2015 : 12:08:54 PM
I agree that it is not ideal solution, but you can accept or move next during replacement.

If you need to reformat too many of lines, then I would recommend you to use some extension for Visual Studio such as AStyle or clang-format.

Usually we don't focus on cases which already have free or opensource solutions available (like reformatting), so even if I would create a case for such tool, it would probably not get high priority.
Vertexwahn Posted - Jul 07 2015 : 07:13:26 AM
There are some corner cases where this does not work properly:

Case 1 (multiplication):

- struct pos *points = (struct pos *) glMapBufferRange( GL_SHADER_STORAGE_BUFFER, 0, NUM_PARTICLES * sizeof(struct pos), bufMask );
+ struct pos *points = (struct pos *) glMapBufferRange( GL_SHADER_STORAGE_BUFFER, 0, NUM_PARTICLES  *sizeof(struct pos), bufMask );


Case 2 (bitwise AND):

- if  (nFeatureInfo & nIds)
+ if  (nFeatureInfo  &nIds)


Case 3 (finds only one occurrence)

-  friend std::istream& operator>>(std::istream& is, icmp_header& header)
+  friend std::istream& operator>>(std::istream& is, icmp_header &header)


Case 4 (comments):

 	/** Construction from existing values for mantissa, sign
-	 *  and exponent. No validation is performed.
+	   *and exponent. No validation is performed.
 	 *  @note The exponent is unsigned and biased by #BIAS 
 	 */
Dusan Posted - Jul 02 2015 : 12:51:28 PM
You can use built-in Find and Replace tool with the following regular expression to achieve what you need:

In VS2010 and older:

Pattern to search for:
{[(,]:b*<:i>}{:b*}{[&*]}{:b*}{<:i>}

Replacement:
\\1\\2\\4\\3\\5

From VS2012:

Pattern to search for:
([,(]\\s*\\b(?:_\\w+|[\\w-[0-9_]]\\w*)\\b)(\\s*)([&*])(\\s*)(\\b(?:_\\w+|[\\w-[0-9_]]\\w*)\\b)

Replacement:
$1$2$4$3$5

Did this help?

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000