After the release of QuantLib 1.14, I had again a bit of time to dedicate to my C++11 experiment. Here are a brief recap and the next steps.

I started this experiment mostly out of curiosity, but with the intent of keeping the code integrable with the master branch. Thus, the need to have code that could accommodate both the currently used boost::shared_ptr and the more modern std::shared_ptr. Enter namespace ext.

With that in place, I started looking at ways to migrate the code. The modernize checks in clang-tidy were a natural place to begin; to see how they fared, I applied them one at a time to the code base. Sometimes they succeeded without problems; some other times, hilarity ensued.

Finally, I created a C++11 branch, I applied a couple of modernizations touching a decent part of the code, and I set up an integration build using Travis CI that would merge the branch with master daily, build it, and run most of the test suite.

And with this, the recap is done. Now, the news.

In the months since I set up the daily build, I merged 26 pull requests to master. Of those, 8 failed to merge cleanly with the C++11 branch; I don’t think any of them required more than 10 minutes of work to fix the conflicts. Here is a plot of the lines and files touched by each pull request, with the ones that merged cleanly marked by a blue dot and the ones that didn’t marked by an orange cross.

Merge results

The pull requests that touched most files (between 20 and 30) failed to integrate, and the ones that changed fewest lines succeeded; but apart from that, there’s no clear correlation between the size of the changes and the chance of success. In any case, I’m happy with the results; all in all, the maintenance of the branch cost me a few hours spread over three months. Thus, the experiment will continue.

The next steps will be more of the same. After the 1.14 release, I created and merged two pull requests that allow to switch between Boost and the STL for more classes; one is for boost::function and the other for boost::bind (I might write about them in one of the next posts). As I write this, I’m applying the remaining modernization checks to the C++11 branch. And after I finish, I’ll keep monitoring the integration build and see what happens with the pull requests that come in during the next few months.

In the meantime, I might start thinking about other C++11 features (such as lambdas, constexpr, move semantics, initializer lists and others) that can’t be added automatically but are likely to make the code more efficient or readable. As usual, I’ll tell you how it goes.

Subscribe to my Substack to receive my posts in your inbox, or follow me on Twitter or LinkedIn if you want to be notified of new posts, or subscribe via RSS if you’re the tech type: the buttons for all that are in the footer. Also, I’m available for training, both online and (when possible) on-site: visit my Training page for more information.