I have a large C++ code base ( 500,000+ LOC, 10k files ) and I'm happy with the code but there are several problems with it:
const hasn't been used as much as it should. For example:
class A
{
int foo( B &a )
{
return a.v * 10;
}
};
should really be changed to:
class A
{
int foo( const B &a ) const
{
return a.v * 10;
}
};
It seems like the compiler should know, in most cases, when a function could be const.
It has also been written in standard C++ as of the early 2000s. I would like to change to use auto and for range loops so
std::map< int, std::string >::iterator i = m.start();
for ( ; i != m.end(); i++
...;
to
for ( const auto p : m )
...;
I could hack something together with perl and/or sed that would probably find most of the cases because the code conforms closely to our internal standards but I'm just wondering if there is a real tool out there that will do this and other things that we may want to do? How do you migrate legacy C++ code to a new standard?