Skip to content

Instantly share code, notes, and snippets.

@hydranix
Created March 2, 2023 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hydranix/87eed6c5c38cb52c7ba98a159302647e to your computer and use it in GitHub Desktop.
Save hydranix/87eed6c5c38cb52c7ba98a159302647e to your computer and use it in GitHub Desktop.
Regex to convert C++ const-ref parameter signature
I wanted an easy way to change the ordering of a bunch of
const ref function parameters in visual studio
warning: not all corner cases are covered, use it carefully
Search for:
(const)\s+(\w+)(&)\s+(\w+[^\w])
Replace with:
$2 $1$3 $4
Original:
void FuncName(const typename& arg1, const typename& arg2,
typename&& arg3,
const typename& arg4 = defaultval) const
Replaced:
void FuncName(typename const& arg1, typename const& arg2,
typename&& arg3,
typename const& arg4 = defaultval) const
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment