Boost logo

Boost :

From: Brey, Edward D (EdwardDBrey_at_[hidden])
Date: 2002-02-06 10:17:00

> From: vesa_karvonen [mailto:vesa_karvonen_at_[hidden]]
> --- In boost_at_y..., "Brey, Edward D" <EdwardDBrey_at_e...> wrote:
> >Suppose I'm coding along in my project and I find I need a
> >scoped_ptr. I include <boost/smart_ptr.hpp> in my precompiled
> >header. I pay for a recompile of everything. It's worth it, of
> >course, because subsequent incremental compilations are much
> >faster. Now suppose I need scoped_array. Well, as luck would have
> >it, I don't have to recompile everything. Had I been using maximally
> >small granularity, I would have had to put <boost/scoped_array.hpp>
> >into my precompile header and paid for a full recompile. Instead, by
> >paying for a trivially longer precompilation, which included some
> >classes I didn't immediately use, I saved myself time in the long
> >run.
> I think that your logic is flawed.
> Here is how the scenario would go when using minimal headers:
> When you find that you need scoped_ptr in some translation unit, you
> include it there and recompile only the translation unit.

The problem is that you will may well compile that translation unit fifty
times in the course of making code changes. That's fifty compilations of
scoped_ptr, which could have been just one.
> When you later find that you need scoped_array in some translation
> unit, you include it there and recompile only the translation unit.

Now you're up to a hundred compilations of scoped_ptr. The whole point of
the pch is to avoid recompiling the infrequently-changing headers each time
your "regular" code changes. Scoped_ptr compiles pretty quickly, but not
the less trivial libraries.
> In a very large project, you would have been able to compile and test
> both changes in a couple of minutes using minimal granularity
> headers. With precompiled headers it might have taken all day to
> recompile the whole project.

If you have a huge project, indeed, you may choose not to use a pch
temporarily, and then before you go home for the evening, move the new
library header into your pch and let it rebuild. However, this pattern
works fine whether you have course- or fine-grained headers.

Boost list run by bdawes at, gregod at, cpdaniel at, john at