Modernizing Legacy C++ Code

Download this episode

Download Video


In this session, James McNellis, a developer on the Visual C++ libraries team, will share his experience using elements of modern C++ to improve a large legacy code base. Learn how to apply principles of modern C++ to gradually improve the quality of legacy code and improve maintainability and debuggability.







Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      Craig Gidney

      It looks like the "new, better function implementation" at 21:36 secretly modifies the variable you give to it to be lower case, instead of only returning the lower case version. The input type should be const char&.

    • User profile image

      Craig, the macro itself also assigns to the variable passed in, so char& would be a faithful port to a function in that case. Of course, the question stands why one would want such a macro or function, but that's something probably better left to another refactoring step, I guess.

    • User profile image

      Couldn't you just write &(pfd.get()) at 25:20 to get the address of the raw pointer?

    • User profile image

      @Michael: It wouldn't work. The pfd.get() call result is a temporary value, not a reference to the underlying pointer.

    • User profile image

      One massive reason that the STL algorithms are underused is that their interface sucks.
      Where "sucks" means "requires odious use of being+end pairs, insead of the infinitely more sensible use of the container itself".
      auto the_max = std::max_element(v);  // <- this is what the library should offer.  underutilization is an absolutely direct result of this failure.

    • User profile image

      @Mordachai: There's a Ranges study group that is working on your first point. As for the second, an extra star is really not much to ask for the ability to know where the maximum is.

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.