Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost and C++ "physical design"
From: Joachim Pihl (jpihl_at_[hidden])
Date: 2009-03-20 05:39:25

On Fri, 20 Mar 2009 10:20:21 +0100, Yang Zhang <yanghatespam_at_[hidden]>

> Is there any advice on taming (1) the generated code size and/or (2) the
> build times* which result from using a header-mostly library like Boost?
> A large C++ project consists of many translation units (.o files)
> which are generated from source files that include many of the same
> Boost headers over and over again. (2) can be ameliorated with a
> distributed build process, but the more general issue here is that of
> consumption of compute resources, be it time or machines.

I can't say much about (1), but for (2) I can share some experience. Most
of the compile time comes from recompiling the same headers over and over
again, so reducing the number of header files parsed for each translation
unit pays dividends.

We use forward declarations in header files extensively, and only include
header files in header files where ABSOLUTELY necessary. This sometimes
means that we use pointers and shared_ptr<>s for holding stuff that is
strictly speaking an accumulated class member, depending how much code
includes the class in question. A forward declared "pimpl" can also help a


Joachim Pihl
Senior R&D Engineer
Tel: +47 33 48 94 66
Fax: +47 33 48 99 98
Mobile: +47 91 33 98 91
The Global Video Transport Leader

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at