Modernizing Legacy C++ Code

Sign in to queue

Description

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.

Tag:

Developer

Day:

1

Embed

Download

Download this episode

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
    Joey

    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
    Michael

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

  • User profile image
    mwu

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

  • User profile image
    Mordachai

    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
    Chris

    @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.

Add Your 2 Cents