1

I extracted some template methods for dealing with STL containers, so a vector of any type can use the function customPushBack(&vec, item) where the item will only be pushed back if it isn't already in the vector and certain conditions are met.

Do I have to manually go to all of the files where the code has been written manually and replace it with my new function call? There are literally thousands of places this shows up in this project, and I can't use simple find/replace because the vector types could all be different.

Could I possibly use Visual Assist or some other tool to help me?

Any advice would be appreciated!

James Mart
  • 560
  • 3
  • 16
  • What kind of code it is, if you have thousands of code duplication? As far as I know, you'll have to manually go and replace – BЈовић Jun 30 '15 at 09:28
  • It's a company I started working for, a lot of the code is 10+ years old and some of the code practices that have been put up with are atrocious. Semi-conductor assembly equipment code. – James Mart Jun 30 '15 at 09:30
  • 1
    With libclang, you may use matcher on the AST and do the replacement. – Jarod42 Jun 30 '15 at 09:32
  • Thanks @Jarod42, I'll look into that – James Mart Jun 30 '15 at 09:33
  • build a wrapper class around the vector class then. You will have to do it anyways if you want to extend the stl class so just build around it instead. –  Jun 30 '15 at 09:34
  • @nilo Well the problem is more the fact that I have to update all the places that this code pattern is used throughout the project. Thanks though – James Mart Jun 30 '15 at 09:36
  • Our CloneDR tool won't help you with replacement, but it will find all the clones and show you what amounts to the abstracted code across the set of clones found. See http://www.semanticdesigns.com/Products/Clone/CppCloneDR.html – Ira Baxter Jun 30 '15 at 13:45
  • Thanks @IraBaxter, I'll check it out – James Mart Jun 30 '15 at 14:56

0 Answers0