Boost logo

Boost :

From: Matthew Herrmann (matthew.herrmann_at_[hidden])
Date: 2007-04-04 02:04:10

> Message: 11
> Date: Tue, 3 Apr 2007 22:23:19 -0400
> From: Jody Hagins <jody-boost-011304_at_[hidden]>
> Subject: Re: [boost] [system] Why is this not header-only?
> To: boost_at_[hidden]
> Message-ID: <20070403222319.6745f5c9.jody-boost-011304_at_[hidden]>
> Content-Type: text/plain; charset=US-ASCII
> On Wed, 4 Apr 2007 00:43:22 +0000 (UTC)
> Steven Watanabe <steven_at_[hidden]> wrote:
>> >
>> > There's always explicit instantiation.
> Right. However, that's not free either. In fact, it adds significant
> developer overhead to get all the explicit instantiations right.
> Note, I understand the "library implemented in a header" for templates.
> I still think there's ways to put parts of them in libraries, especially
> when providing wrappers around system resources.

For system resources, I find the inline pimpl idiom is quite useful:

First, design the class as a pimpl. You then create an ipp file and
selectively #include it in the header file, with the pimpl definition.
The ipp file also contains all of the includes needed for the pimpl
definition. The only trick is that the "inline" keyword needs to be
selectively prefaced to the class's member function definitions to make
linking work correctly. That can be done with a macro.

You get the best of both worlds. When in debug mode, with static
libraries pre-built, the libraries have practically no compile-time
performance. Flick a #define on in release mode, for example, and you
get maximum inlining and slow compiles. This technique doesn't work for
very simple data types since it still incurs the pimpl's dynamic memory
allocation overhead on construction.

Jody -- re: boost build, I'd recommend checking out their specific
mailing list. It's hard to get started, and error messages are
frequently very misleading, but it's the best C++ build tool I've seen yet.

Matthew Herrmann

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