
On Mon, Mar 15, 2021 at 9:06 AM Mike via Boost <boost@lists.boost.org> wrote:
...
There's a new sheriff in town, an alternative to the traditional paradigms of header-only and pre-built library. I call it "included source." It offers the fast compilation of a pre-built library with the ease of integration of a pre-built library. It doesn't require or depend on any particular build system. Credit to Christopher Kohlhoff for using this technique in Boost.ASIO, which I copied in my projects. Boost.JSON offers this method as an alternative to building a static or share library. It works like this. Simply place the following line in exactly one new or existing source file in the program where you want to use Boost.JSON: #include <boost/json/src.hpp> That's it! This is basically how the static and shared libraries are built. The build scripts just compile this file src.cpp which has the include line above: <https://github.com/boostorg/json/blob/develop/src/src.cpp> This makes it very easy to add Boost.JSON to your existing project. You also get the benefit that the optimizer has access to all of the library's function definitions at once, like a poor man's "global program optimization." Plus, it makes it easy to use on compiler explorer: <https://godbolt.org/z/zPjv9M> This is the technique that I will be using for all my new libraries. Furthermore, to reduce compilation times and make things easier to use, when designing classes and functions I try to avoid templates where it makes sense to do so. This allows more code to be placed out of line. You can read more about this here: <https://github.com/boostorg/json#header-only> Thanks