Header-only Libraries
Over the course of the last couple of years I’ve been gradually building and refining a software framework for the purpose of creating signal processing receiver structures in C++. But as new analysis programs have been built I’ve just copied the files over to start afresh. Improvements to the framework have only really been captured in the absolute latest analysis program. It didn’t make sense to create a standalone library before as the compile-time options vary from analysis program to analysis program.
I am now looking to create a library version of the framework and have been looking at options. Much (most) of the code is actually template C++ header files which would lend it rather well to a header-only library.
An example of a header-only library: TCLAP is a really handy library for handling command line parameters.
Before making the decision I was interested in the pros and cons of going down the route of a header-only library. There is a particularly in-depth Q&A on Stack Overflow that looks into the actual quantifiable metrics between header-only vs traditional libraries.
Stack Overflow Q&A: Quantifiable metrics (benchmarks) on the usage of header-only c++ libraries.
There are costs with regards the compile time (and recompile time) however, as much of the library is template C++ there wouldn’t be much benefit (compile time) in using the traditional library approach.
There are, however, numerous Q&As on the qualitative aspects and personal preferences of header-only versus traditional libraries.
Stack Overflow Q&A: When are header-only libraries acceptable?
Stack Overflow Q&A: C++ code in header files
So the decision is to give the header-only library approach a go and see how it works out.